3

I created a new branch.

After some modification I would like to push the branch to the server

git commit  -m 'New branch'

13 files changed, 694 insertions(+), 36 deletions(-)

git push origin malix1.0
Everything up-to-date

Why it is everything up to date?

 git branch
* (no branch)
  malix1.0

Where am I making the mistakes?

Kicsi Mano
  • 3,551
  • 3
  • 21
  • 26

1 Answers1

3

I think that after you created that new branch "malix1.0" you somehow managed to put the repository in what is called the "detached HEAD" state, and so your new commit wasn't recorded on that branch.

Then, when you run git push origin malix1.0 Git takes the contents of that "malix1.0" branch and tries to update the same-named branch in the remote repository. Since the branch does not contain anything new compared to its matching branch in the remote repo, nothing happens.

To get out of this situation, do this:

  1. Make a branch out of your current state:

    git branch temp
    

    Otherwise you will need to rely on the git reflog functionality to get hold on your work after you check out a branch.

  2. Update your "mailx1.0" branch with your work:

    git checkout mailx1.0
    git merge temp
    

    That is, you check out the branch which was intended to receive your new commits and then merge in the temporary branch which is actually holding those commits.

  3. Delete that temporary branch:

    git branch -d temp
    

    This branch is no longer needed as the work it contained compared to "mailx1.0" is now on that "mailx1.0" branch as well.

  4. Push out your updated branch:

    git push origin mailx1.0
    
Community
  • 1
  • 1
kostix
  • 51,517
  • 14
  • 93
  • 176
  • See also [this](http://stackoverflow.com/a/5772882/720999) and [this](http://stackoverflow.com/search?q=[git]+detached+HEAD) in general. – kostix Apr 26 '13 at 16:19
  • I had to modify the step 2: `git checkout -b mailx1.0 origin/malix1.0`. But everything else worked perfectly. Thank you. http://stackoverflow.com/questions/1783405/git-checkout-remote-branch – Kicsi Mano Apr 29 '13 at 08:21
  • @KicsiMano, I wonder why you had to *create* `malix1.0` out of `origin/malix1.0` for the output of `git branch` you cited clearly included that branch `malix1.0`. ;-) Anyway, good it's worked for you! – kostix Apr 29 '13 at 12:53