Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git push won't do anything (everything up-to-date)

Tags:

git

dvcs

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) 
like image 952
Jamie Wong Avatar asked May 29 '10 21:05

Jamie Wong


People also ask

When I do git push it says everything up-to-date?

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 later git prune or git gc would garbage-collect them. If you did this by mistake, you can ask the reflog for HEAD where you were, e.g.

Why is git push not working?

If git push origin master not working , all you need to do is edit that file with your favourite editor and change the URL = setting to your new location. Assuming the new repository is correctly set up and you have your URL right, you'll easily be able to push and pull to and from your new remote location.

What does everything up-to-date mean?

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.

Why does git say up-to-date when its not?

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.


2 Answers

git push doesn'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 origin it actually prints out which branches are configured for push:

Local refs configured for 'git push':   master pushes to master (up to date)   quux   pushes to quux   (fast forwardable) 

Q. But I could push to master without worrying about all this!

When you git clone, by default it sets up your local master branch to push to the remote's master branch (locally referred to as origin/master), so if you only commit on master, then a simple git push will 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. So git push without 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 develop into origin/master, then you should probably merge them into your local master then push that:

git checkout master git merge develop git push             # will push 'master' 

If what you want is to create a develop branch on the remote, separate from master, then supply arguments to git push:

git push origin develop 

That will: create a new branch on the remote called develop; and bring that branch up to date with your local develop branch; and set develop to push to origin/develop so that in future, git push without arguments will push develop automatically.

If you want to push your local develop to a remote branch called something other than develop, then you can say:

git push origin develop:something-else 

However, that form won't set up develop to always push to origin/something-else in future; it's a one-shot operation.

like image 162
Sam Stokes Avatar answered Sep 24 '22 11:09

Sam Stokes


This happened to me when my SourceTree application crashed during staging. And on the command line, it seemed like the previous git add had been corrupted. If this is the case, try:

git init git add -A git commit -m 'Fix bad repo' git push 

On the last command, you might need to set the branch.

git push --all origin master 

Bear in mind that this is enough if you haven't done any branching or any of that sort. In that case, make sure you push to the correct branch like git push origin develop.

like image 25
Vik Avatar answered Sep 20 '22 11:09

Vik