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.
You need to use git pull and resolve the difference between your local changes and the remote changes before you can git push . There is still a commit in the remote branch initializing the repo that may not be in your local version.
To push changes from the current branch press Ctrl+Shift+K or choose Git | Push from the main menu. To push changes from any local branch that has a remote, select this branch in the Branches popup and choose Push from the list of actions.
To force a push to only one branch, use a + in front of the refspec to push (e.g git push origin +master to force a push to the master branch).
Are you working with a detached head by any chance?
As in:
indicating that your latest commit is not a branch head.
Warning: the following does a git reset --hard
: make sure to use git stash
first if you want to save your currently modified files.
$ git log -1
# note the SHA-1 of latest commit
$ git checkout master
# reset your branch head to your previously detached commit
$ git reset --hard <commit-id>
As mentioned in the git checkout
man page (emphasis mine):
It is sometimes useful to be able to checkout a commit that is not at the tip of one of your branches.
The most obvious example is to check out the commit at a tagged official release point, like this:
$ git checkout v2.6.18
Earlier versions of git did not allow this and asked you to create a temporary branch using the
-b
option, but starting from version 1.5.0, the above command detaches yourHEAD
from the current branch and directly points at the commit named by the tag (v2.6.18
in the example above).You can use all git commands while in this state.
You can usegit reset --hard $othercommit
to further move around, for example.
You can make changes and create a new commit on top of a detached HEAD.
You can even create a merge by usinggit merge $othercommit
.The state you are in while your HEAD is detached is not recorded by any branch (which is natural --- you are not on any branch).
What this means is that you can discard your temporary commits and merges by switching back to an existing branch (e.g.git checkout master
), and a latergit prune
orgit gc
would garbage-collect them.
If you did this by mistake, you can ask the reflog for HEAD where you were, e.g.
$ git log -g -2 HEAD
Err.. If you are a git noob are you sure you have git commit
before git push
? I made this mistake the first time!
Maybe you're pushing a new local branch?
A new local branch must be pushed explicitly:
git push origin your-new-branch-name
Just one of those things about git... You clone a repo, make a branch, commit some changes, push... "Everything is up to date". I understand why it happens, but this workflow is extremely unfriendly to newcomers.
My issue was that my local branch had a different name than the remote branch. I was able to push by doing the following:
$ git push origin local-branch-name:remote-branch-name
(Credit to https://penandpants.com/2013/02/07/git-pushing-to-a-remote-branch-with-a-different-name/)
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