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:
- Git/Bonobo - Add local repository to remote
- How can I run “git status” and just get the filenames
- Cherry-pick a merge
- How to migrate to Git from this setup (svn)
- Version control for reports (git)
- How can I create a new branch in git from an existing file tree?
- 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)
git add file/to/restore
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
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 ?
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
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.
git checkout man page:
git checkout <branch>
<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