Git development
 help / color / mirror / Atom feed
* How to force a push to succeed?
@ 2017-08-22 21:55 Jeffrey Walton
  2017-08-22 21:57 ` Stefan Beller
  2017-08-23  8:03 ` Kevin Daudt
  0 siblings, 2 replies; 8+ messages in thread
From: Jeffrey Walton @ 2017-08-22 21:55 UTC (permalink / raw)
  To: Git List

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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to force a push to succeed?
  2017-08-22 21:55 How to force a push to succeed? Jeffrey Walton
@ 2017-08-22 21:57 ` Stefan Beller
  2017-08-22 22:03   ` Jeffrey Walton
  2017-08-23  8:03 ` Kevin Daudt
  1 sibling, 1 reply; 8+ messages in thread
From: Stefan Beller @ 2017-08-22 21:57 UTC (permalink / raw)
  To: Jeffrey Walton; +Cc: Git List

On Tue, Aug 22, 2017 at 2:55 PM, Jeffrey Walton <noloader@gmail.com> wrote:
> 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.

Checkout the --force[-with-lease] argument.

https://git-scm.com/docs/git-push

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to force a push to succeed?
  2017-08-22 21:57 ` Stefan Beller
@ 2017-08-22 22:03   ` Jeffrey Walton
  2017-08-22 22:10     ` Jeffrey Walton
  0 siblings, 1 reply; 8+ messages in thread
From: Jeffrey Walton @ 2017-08-22 22:03 UTC (permalink / raw)
  To: Stefan Beller; +Cc: Git List

On Tue, Aug 22, 2017 at 5:57 PM, Stefan Beller <sbeller@google.com> wrote:
> On Tue, Aug 22, 2017 at 2:55 PM, Jeffrey Walton <noloader@gmail.com> wrote:
>> 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.
>
> Checkout the --force[-with-lease] argument.

Perfect, thanks.

Jeff

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to force a push to succeed?
  2017-08-22 22:03   ` Jeffrey Walton
@ 2017-08-22 22:10     ` Jeffrey Walton
  2017-08-22 22:26       ` Jeffrey Walton
  2017-08-23 16:56       ` Jonathan Nieder
  0 siblings, 2 replies; 8+ messages in thread
From: Jeffrey Walton @ 2017-08-22 22:10 UTC (permalink / raw)
  To: Stefan Beller; +Cc: Git List

On Tue, Aug 22, 2017 at 6:03 PM, Jeffrey Walton <noloader@gmail.com> wrote:
> On Tue, Aug 22, 2017 at 5:57 PM, Stefan Beller <sbeller@google.com> wrote:
>> On Tue, Aug 22, 2017 at 2:55 PM, Jeffrey Walton <noloader@gmail.com> wrote:
>>> 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.
>>
>> Checkout the --force[-with-lease] argument.

Thanks again Stefan,

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)
Already up-to-date.
via:$ cat integer.cpp | grep ADX
#if defined(CRYPTOPP_ADX_AVAILABLE)
# define CRYPTOPP_INTEGER_ADX 1
#if CRYPTOPP_INTEGER_SSE2 || CRYPTOPP_INTEGER_ADX
#if CRYPTOPP_INTEGER_ADX
extern int CRYPTOPP_FASTCALL ADX_Add(size_t N, word *C, const word *A,
const word *B);
#if CRYPTOPP_INTEGER_ADX
        if (HasADX())
                s_pAdd = &ADX_Add;
#if CRYPTOPP_INTEGER_SSE2 || CRYPTOPP_INTEGER_ADX

Above, there should be no references to ADX. Looking at the GitHub the
changes have been applied.

Any ideas?

Jeff

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to force a push to succeed?
  2017-08-22 22:10     ` Jeffrey Walton
@ 2017-08-22 22:26       ` Jeffrey Walton
  2017-08-23 17:06         ` Johannes Sixt
  2017-08-23 16:56       ` Jonathan Nieder
  1 sibling, 1 reply; 8+ messages in thread
From: Jeffrey Walton @ 2017-08-22 22:26 UTC (permalink / raw)
  To: Stefan Beller; +Cc: Git List

>>>> 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.
>>>
>>> Checkout the --force[-with-lease] argument.
>
> Thanks again Stefan,
>
> 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)
> Already up-to-date.
> via:$ cat integer.cpp | grep ADX
> #if defined(CRYPTOPP_ADX_AVAILABLE)
> # define CRYPTOPP_INTEGER_ADX 1
> #if CRYPTOPP_INTEGER_SSE2 || CRYPTOPP_INTEGER_ADX
> #if CRYPTOPP_INTEGER_ADX
> extern int CRYPTOPP_FASTCALL ADX_Add(size_t N, word *C, const word *A,
> const word *B);
> #if CRYPTOPP_INTEGER_ADX
>         if (HasADX())
>                 s_pAdd = &ADX_Add;
> #if CRYPTOPP_INTEGER_SSE2 || CRYPTOPP_INTEGER_ADX
>
> Above, there should be no references to ADX. Looking at the GitHub the
> changes have been applied.
>
> Any ideas?

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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to force a push to succeed?
  2017-08-22 21:55 How to force a push to succeed? Jeffrey Walton
  2017-08-22 21:57 ` Stefan Beller
@ 2017-08-23  8:03 ` Kevin Daudt
  1 sibling, 0 replies; 8+ messages in thread
From: Kevin Daudt @ 2017-08-23  8:03 UTC (permalink / raw)
  To: Jeffrey Walton; +Cc: Git List

On Tue, Aug 22, 2017 at 05:55:25PM -0400, Jeffrey Walton wrote:
> 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.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to force a push to succeed?
  2017-08-22 22:10     ` Jeffrey Walton
  2017-08-22 22:26       ` Jeffrey Walton
@ 2017-08-23 16:56       ` Jonathan Nieder
  1 sibling, 0 replies; 8+ messages in thread
From: Jonathan Nieder @ 2017-08-23 16:56 UTC (permalink / raw)
  To: Jeffrey Walton; +Cc: Stefan Beller, Git List

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to force a push to succeed?
  2017-08-22 22:26       ` Jeffrey Walton
@ 2017-08-23 17:06         ` Johannes Sixt
  0 siblings, 0 replies; 8+ messages in thread
From: Johannes Sixt @ 2017-08-23 17:06 UTC (permalink / raw)
  To: noloader; +Cc: Stefan Beller, Git List

Am 23.08.2017 um 00:26 schrieb Jeffrey Walton:
> 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.

No, no. So simple your task might look, in the end you have LOST DATA! 
It is a design goal of Git to make it difficult to lose data.

-- Hannes

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-08-23 17:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-22 21:55 How to force a push to succeed? Jeffrey Walton
2017-08-22 21:57 ` Stefan Beller
2017-08-22 22:03   ` Jeffrey Walton
2017-08-22 22:10     ` Jeffrey Walton
2017-08-22 22:26       ` Jeffrey Walton
2017-08-23 17:06         ` Johannes Sixt
2017-08-23 16:56       ` Jonathan Nieder
2017-08-23  8:03 ` Kevin Daudt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox