I can't push my changes to remote server (up to date)

Here is all the need:

I have a remote branch (fix branch) called /fix/version-1.x which have two commits:

  • First commit done by user A
  • Second commit by user B (Me)

It turned out that this branch is not correct (more precisely my second commit) : there was some implementation error on one file

As first step :

1- I have downloaded this branch (with the two commit)

so as first reaction i made a simple checkout for this file to the previous commit (the first one) as there was no implementation error there .

2- I checked out the first commit (only for this file)

git checkout 'commit' file/to/restore

3- I got a 'detached HEAD' with git branch command

4- I made the cahnge for this file (correction)

5- git add file/to/restore

6- git status OK

7- I made a commit with a new msg git commit -m "solve implementation error problem"

when I push my local branch to the remote server
8- git push remote fix/version-1.x

It tell me that there is every thing is up to date (already updated) nothing to do !!!

but when I’m working without checking out the file to the previous state (the fist commit), ie i made the change directly on this branch and made a commit then push to the remote server every thing is working correctly and i have the new commit (third one ) on the remote server.

It seems that the problem comes from this detached head ? I ‘m doing wrong here ?

  • Working with GIT on two remote repositories
  • Is `hg pull --rebase` analogous to `svn update`?
  • Git Pull Errors After Forced Push — Trying To Avoid Hard Reset
  • git diff between cloned and original remote repository
  • Best way to do Version Control for MS Excel
  • Remove Git binding from Visual Studio 2013 solution?
  • Not visible GIT push
  • Distributed Version Control Systems and the Enterprise - a Good mix?
  • One Solution collect form web for “I can't push my changes to remote server (up to date)”

    It seems that the problem comes from this detached head

    Indeed. git checkout 'commit' -- file/to/restore should have reset only that specific file without detaching the HEAD.
    That detached HEAD status must have come from step1.

    What step1 should look like would be:

    git clone url/remote/repo/
    cd repo
    git checkout fix/version-1.x
    

    That local branch will be automatically linked to its upstream branch.
    From git checkout man page:

    git checkout <branch>
    

    If <branch> is not found but there does exist a tracking branch in exactly one remote (call it <remote>) with a matching name, treat as equivalent to:

    git checkout -b <branch> --track <remote>/<branch>
    

    Then you can proceed with git checkout 'commit' -- file/to/restore

    Git Baby is a git and github fan, let's start git clone.