Question

Being a total Noob, I am not able to work with SmartGit at all. Git Terminologies are too confusing.

Here is what I did, I created two Repositories, Repo1, and Repo2 In SmartGit

  1. Initialized Repo1 as GIT
  2. Cloned Repo1 to Repo2
  3. Added a text file in Repo1 and added some text to it.
  4. Pulled for Repo2
  5. made few changes in the text file
  6. Committed
  7. Now when I am trying to Push these changes to Repo1 I am getting "Not all refs have been pushed" error"

Update:

Push: Not all refs have been pushed.
    'master' rejected (non-fast-forward)
    Counting objects: 10, done.
    Delta compression using up to 2 threads.
    Compressing objects:  20% (1/5)   
    Compressing objects:  40% (2/5)   
    Compressing objects:  60% (3/5)   
    Compressing objects:  80% (4/5)   
    Compressing objects: 100% (5/5)   
    Compressing objects: 100% (5/5), done.
    Writing objects:  12% (1/8)   
    Writing objects:  25% (2/8)   
    Writing objects:  37% (3/8)   
    Writing objects:  50% (4/8)   
    Writing objects:  62% (5/8)   
    Writing objects:  75% (6/8)   
    Writing objects:  87% (7/8)   
    Writing objects: 100% (8/8)   
    Writing objects: 100% (8/8), 726 bytes, done.
    Total 8 (delta 0), reused 0 (delta 0)
    remote: error: refusing to update checked out branch: refs/heads/master
    remote: error: By default, updating the current branch in a non-bare repository
    remote: error: is denied, because it will make the index and work tree inconsistent
    remote: error: with what you pushed, and will require 'git reset --hard' to match
    remote: error: the work tree to HEAD.
    remote: error: 
    remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
    remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
    remote: error: its current branch; however, this is not recommended unless you
    remote: error: arranged to update its work tree to match what you pushed in some
    remote: error: other way.
    remote: error: 
    remote: error: To squelch this message and still keep the default behaviour, set
    remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
    error: failed to push some refs to '/home/sdr1/Desktop/LocalRepository'
Was it helpful?

Solution

Please read the part of the error message:

remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.

Git prevents to push into a branch of a non-bare repository (here Repo1), because this would make the working tree, index and HEAD inconsistent or very error prone.

Solution: Switch your original repository (Repo1) to a different branch and try again to push from the clone (Repo2).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top