Re: "git push" silently fails, says 'Everything up-to-date" when it's not.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David Woodhouse <dwmw2@xxxxxxxxxxxxx> writes:

> [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/
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]