Re: "git push" silently fails, says 'Everything up-to-date" when it's not.
- From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
- Date
- May 28, 2012, 12:11 UTC
- Message-ID
- <vpqipfgec9k.fsf@bauges.imag.fr>
- In-Reply-To
- <1338206011.11518.115.camel@shinybook.infradead.org>
David Woodhouse <dwmw2@infradead.org> writes:
Show 7 quoted lines
> [dwmw2@shinybook mtd-2.6]$ git push > Everything up-to-date > > But it lies. Only when I try to *pull* does it give me a hint: > > [dwmw2@shinybook mtd-2.6]$ git pull > You are not currently on a branch, so I cannot use any
What does
git config push.default
say?
You probably have push.default=matching, which is the default. In this mode, Git will push all your local branches to remote branches having the same name (regardless of which branch you currently have checked-out). The commits you just did were not on any branch, so they're not pushed.
> Why would it do this evil thing and start lying to me? When it told me > 'Everything up-to-date', precisely *what* was it telling me was up to > date? Did it ever push *anything*, *anywhere*, or was it just a complete > fabrication?
It probably pushed your branches, but not commits done in detached HEAD.
> I don't quite know how I ended up "not currently on a branch" either.
Either you did "git checkout <some-commit-identifier>" (in which case you had a big fat warning), or you used one command that runs in detached HEAD like "git rebase" or "git bisect" without concluding the operation ("git bisect reset", "git rebase --continue" or so).
With a recent enough version of Git, each commit you did in detached head had this little reminder:
$ git commit -m foo [detached HEAD acb1d5b] foo ^^^^^^^^^^^^^
As for the future, there's a patch serie in progress that will make "git status" warn a bit more loudly in these cases, and give you a clue about what to do next.
In Git 2.0, the push.default value will change to "simple", which errors out like this in your case:
$ git push fatal: You are not currently on a branch. To push the history leading to the current (detached HEAD) state now, use
git push origin HEAD:<name-of-remote-branch>
If you can't wait to have this "simple" mode, you may want to set push.default=upstream (or current), which will push the current branch to its upstream (or to the one with the same name remotely).
I don't know what can be done to improve the case of detached HEAD with push.default=matching. Perhaps Git should warn when HEAD is not pushed (detached HEAD, or HEAD points to a branch that doesn't exist remotely)?
-- Matthieu Moy http://www-verimag.imag.fr/~moy/