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)...?)
To fix this, follow the steps below. To save your files, use the git stash command. Then look at the log and get the SHA-1 of the latest commit. Reset the branch head to previously detached commit with the git reset command.
1 : extending up to the present time : including the latest information up-to-date maps. 2 : abreast of the times : modern up-to-date methods.
If the current branch is not outdated compared to the one you pull from, pull will say Already up-to-date. even if you have local changes in your working directory. git pull is concerned with branches, not the working tree — it will comment on the working tree only if there are changes which interfere with the merge.
To push a branch on remote, your branch needs to have the latest changes present in remote repository. If you get the failed to push error, first do git pull the branch to get the latest commits and then push it.
git branch -v indicates that my commit was on (no branch). As for the add, I initially commited the changes through Eclipse (with the git plugin)...when I do git add from the command line, it doesn't seem to do anything
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?" HEAD
explained".HEAD
with master/origin?"The OP mentions this article in order to fix the situation:
"git: what to do if you commit to no branch"
all we need to do is checkout the branch we should have been on and merge in that commit SHA:
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 HEAD
back to the right branch.
After you change files, you need to
git add
them prior to
git commit
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With