Re: How to force a push to succeed?

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

 



Hi Jeffrey,

Jeffrey Walton wrote:

> From another testing machine, it looks like the changes have not been
> backed out. The previous operation un-did the ADX gear because it was
> an evolutionary dead-end.
>
> via$ git pull
> From https://github.com/noloader/cryptopp
>  + 66654dd...559fc3b master     -> origin/master  (forced update)

The Git User Manual[1] explains:

| We have already seen how to keep remote-tracking branches up to date
| with git-fetch(1), and how to merge two branches. So you can merge
| in changes from the original repository’s master branch with:
|
| $ git fetch
| $ git merge origin/master
|
| However, the git-pull(1) command provides a way to do this in one step:
|
| $ git pull origin master

There is also some discussion of that in "git help pull".

But that doesn't appear to be what you want to do.  You are not
looking to incorporate remote changes into your local branch,
preserving any changes that are in your local branch --- instead, you
are looking to move to what the remote server has, overwriting any
changes that are in your local branch.

You can do that with

	git fetch
	git reset --hard origin/master

See also the discussion of --force in "git help push".

I also recommend looking at the Git Tutorial[2].  When it introduces
"git reset --hard" to back out changes, it says:

| $ git reset --hard HEAD^ # reset your current branch and working
|                          # directory to its state at HEAD^
|
| Be careful with that last command: in addition to losing any changes
| in the working directory, it will also remove all later commits from
| this branch. If this branch is the only branch containing those
| commits, they will be lost. Also, don’t use git reset on a
| publicly-visible branch that other developers pull from, as it will
| force needless merges on other developers to clean up the history.
| If you need to undo changes that you have pushed, use git revert
| instead.

If you have ideas about how it could explain this better (or even
better, how commands could behave to avoid needing such explanation)
then I would be happy to hear them.

(Side note: I am starting to wonder whether what you were looking for
was something like "git revert", especially if this is a project
involving more than one person.)

> You know, I look at how fucked up yet another simple workflow is, and
> all I can do is wonder. It is absolutely amazing. Its like the project
> goes out of its way to make simple tasks difficult.

I understand your frustration, but accusing people of trying to make
your life difficult isn't a particularly productive way to get help
from them.

For the future, some ways to get good results are

- to describe the background of what you are trying to do
- to describe where you looked for answers, so that we know what
  documentation to improve

The #git IRC channel on freenode can also be helpful for real-time
help.  But I encourage you to also keep writing here so that we know
what documentation and workflows to improve.

Thanks and hope that helps,
Jonatha

[1] https://www.kernel.org/pub/software/scm/git/docs/user-manual.html#getting-updates-With-git-pull
[2] https://www.kernel.org/pub/software/scm/git/docs/gittutorial.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]

  Powered by Linux