git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: How to force a push to succeed?

From
Kevin Daudt <me@ikke.info>
Date
Aug 23, 2017, 08:03 UTC
Message-ID
<20170823080328.GE3839@alpha.vpn.ikke.info>
In-Reply-To
<CAH8yC8=A0-geqduTNNJw0yb1BREqsB75_bKSp+06Rb5fY6oiuQ@mail.gmail.com>
On Tue, Aug 22, 2017 at 05:55:25PM -0400, Jeffrey Walton wrote:
Show 28 quoted lines
> I tested some changes that lead to a dead end. The changes need to be
> removed. The changes were added in 7 commits.
> 
> I went back in time to the point before the changes:
> 
>     $ git reset --hard HEAD~7
>     HEAD is now at 559fc3b Fix benchmark selection code (GH #464)
> 
> When I attempted to push:
> 
>     $ git push
>     Username for 'https://github.com': noloader
>     To https://github.com/noloader/cryptopp.git
>      ! [rejected]        master -> master (non-fast-forward)
> 
> I tried to commit, but Git claims there's nothing to add:
> 
>     $ git commit
>     On branch master
>     Your branch is behind 'origin/master' by 7 commits, and can be
> fast-forwarded.
> 
> Commit seems to be the wrong command as Git appears to be trying to do
> something I don't want.
> 
> How do I force the push to succeed?
> 
> Thanks in advance.
By actually doing a force push:
    git push --force-with-lease origin master

But note that this can interfere with others working on the same repository, so be carefull when you use a force push.

Additionally, I can recommend using separate branches for things that might turn up as dead ends (or even for every development). That way, you can just throw away the branch if you want to discard it.

Hope this helps, Kevin.
Previous: Jonathan Nieder
Message 8 of 8 in “How to force a push to succeed?”
  1. Jeffrey WaltonAug 22, 2017
  2. Stefan BellerAug 22, 2017
  3. Jeffrey WaltonAug 22, 2017
  4. Jeffrey WaltonAug 22, 2017
  5. Jeffrey WaltonAug 22, 2017
  6. Johannes SixtAug 23, 2017
  7. Jonathan NiederAug 23, 2017
  8. Kevin DaudtAug 23, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.