On github, I forked an old version of another project. I made some changes and am trying to push them onto my fork on github. I commited the changes locally, then tried git push, but this simply tells me “Everything up-to-date”. When I browse the project on github, however, nothing has changed: it still shows the files (from the latest version) on my fork, unmodified. How can I push the changes to my github account?
(I realize this isn’t much information…what else can I say? I have a feeling that it may be because I’m modifying the files directly in (home)/git/(project)…?)
That means you are in a DETACHED HEAD mode.
You can add and commit, but from the upstream repo point of view (ie from the GitHub repo), no new commits are ready to be pushed.
You have various ways to include your local (detached
HEAD) commit back into a branch, which you will be able to push then.See:
git commit+ checkout when not in any branch. Did I loose my changes?”HEADexplained“.HEADwith master/origin?“The OP mentions this article in order to fix the situation:
“git: what to do if you commit to no branch“
Note that instead of merging the SHA1 that you would have somehow copied, you can memorize it with a script, using
head=$(git rev-parse HEAD):See “git: reliably switching to a detached HEAD and then restore HEAD later, all from a script“.
Then you can merge that detached
HEADback to the right branch.