I’m trying to update a Git repository on GitHub. I made a bunch of changes, added them, committed then attempted to do a git push. The response tells me that everything is up to date, but clearly it’s not.
git remote show origin
responds with the repository I’d expect.
Why is Git telling me the repository is up to date when there are local commits that aren’t visible on the repository?
[searchgraph] git status
# On branch develop
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# Capfile
# config/deploy.rb
nothing added to commit but untracked files present (use "git add" to track)
[searchgraph] git add .
[searchgraph] git status
# On branch develop
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: Capfile
# new file: config/deploy.rb
#
[searchgraph] git commit -m "Added Capistrano deployment"
[develop 12e8af7] Added Capistrano deployment
2 files changed, 26 insertions(+), 0 deletions(-)
create mode 100644 Capfile
create mode 100644 config/deploy.rb
[searchgraph] git push
Everything up-to-date
[searchgraph] git status
# On branch develop
nothing to commit (working directory clean)
git pushdoesn’t push all of your local branches: how would it know which remote branches to push them to? It only pushes local branches which have been configured to push to a particular remote branch.On my version of Git (1.6.5.3), when I run
git remote show originit actually prints out which branches are configured for push:Q. But I could push to
masterwithout worrying about all this!When you
git clone, by default it sets up your localmasterbranch to push to the remote’smasterbranch (locally referred to asorigin/master), so if you only commit onmaster, then a simplegit pushwill always push your changes back.However, from the output snippet you posted, you’re on a branch called
develop, which I’m guessing hasn’t been set up to push to anything. Sogit pushwithout arguments won’t push commits on that branch.When it says “Everything up-to-date”, it means “all the branches you’ve told me how to push are up to date”.
Q. So how can I push my commits?
If what you want to do is put your changes from
developintoorigin/master, then you should probably merge them into your localmasterthen push that:If what you want is to create a
developbranch on the remote, separate frommaster, then supply arguments togit push:That will: create a new branch on the remote called
develop; and bring that branch up to date with your localdevelopbranch; and setdevelopto push toorigin/developso that in future,git pushwithout arguments will pushdevelopautomatically.If you want to push your local
developto a remote branch called something other thandevelop, then you can say:However, that form won’t set up
developto always push toorigin/something-elsein future; it’s a one-shot operation.