git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Why is there no force pull?
@ 2018-06-09 19:01 Christoph Böhmwalder
  2018-06-09 20:04 ` Elijah Newren
  2018-06-10 16:11 ` Torsten Bögershausen
  0 siblings, 2 replies; 5+ messages in thread
From: Christoph Böhmwalder @ 2018-06-09 19:01 UTC (permalink / raw)
  To: git

Hi,

Since this is a use case that actually comes up quite often in
day-to-day use, especially among git beginners, I was wondering: is
there a specific reason why a command like "fetch changes from remote,
overwriting everything in my current working directory including all
commits I've made" doesn't exist? Now, I'm quite aware that something
like

    $ git fetch origin/branch
    $ git reset --hard origin/branch

will do the trick just fine, but (like I mentioned, especially for
beginners) this kind of seems like a crook. Why not have a single
command for accomplishing this? Afterall we do have a `--force` flag on
`git push`, which practically does the same thing in reverse.

Just reaching out to get some input on this, as it seems like a quite
curious inconsistency to me.

--
Regards,
Christoph

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

* Re: Why is there no force pull?
  2018-06-09 19:01 Why is there no force pull? Christoph Böhmwalder
@ 2018-06-09 20:04 ` Elijah Newren
  2018-06-09 20:25   ` Christoph Böhmwalder
  2018-06-09 20:30   ` Ævar Arnfjörð Bjarmason
  2018-06-10 16:11 ` Torsten Bögershausen
  1 sibling, 2 replies; 5+ messages in thread
From: Elijah Newren @ 2018-06-09 20:04 UTC (permalink / raw)
  To: Git Mailing List

On Sat, Jun 9, 2018 at 12:01 PM, Christoph Böhmwalder
<christoph@boehmwalder.at> wrote:
> Hi,
>
> Since this is a use case that actually comes up quite often in
> day-to-day use, especially among git beginners, I was wondering: is
> there a specific reason why a command like "fetch changes from remote,
> overwriting everything in my current working directory including all
> commits I've made" doesn't exist? Now, I'm quite aware that something
> like
>
>     $ git fetch origin/branch
>     $ git reset --hard origin/branch
>
> will do the trick just fine, but (like I mentioned, especially for
> beginners) this kind of seems like a crook. Why not have a single
> command for accomplishing this? Afterall we do have a `--force` flag on
> `git push`, which practically does the same thing in reverse.
>
> Just reaching out to get some input on this, as it seems like a quite
> curious inconsistency to me.

Upon reading the subject and before reading the body, I assumed you
were going to ask for a 'git pull --force' that would throw away
*uncommitted* changes (i.e. do a 'git reset --hard HEAD' before the
rest of the pull).  But then you asked for both uncommitted and
committed changes to be thrown away.  That difference isn't something
you have to consider with a push.

That might be a reason such an option would be confusing, or it might
just be a warning to document the option carefully.  Anyway, thought
I'd mention it.

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

* Re: Why is there no force pull?
  2018-06-09 20:04 ` Elijah Newren
@ 2018-06-09 20:25   ` Christoph Böhmwalder
  2018-06-09 20:30   ` Ævar Arnfjörð Bjarmason
  1 sibling, 0 replies; 5+ messages in thread
From: Christoph Böhmwalder @ 2018-06-09 20:25 UTC (permalink / raw)
  To: Elijah Newren; +Cc: Git Mailing List

On Sat, Jun 09, 2018 at 01:04:30PM -0700, Elijah Newren wrote:
> Upon reading the subject and before reading the body, I assumed you
> were going to ask for a 'git pull --force' that would throw away
> *uncommitted* changes (i.e. do a 'git reset --hard HEAD' before the
> rest of the pull).  But then you asked for both uncommitted and
> committed changes to be thrown away.  That difference isn't something
> you have to consider with a push.
> 
> That might be a reason such an option would be confusing, or it might
> just be a warning to document the option carefully.  Anyway, thought
> I'd mention it.

Interesting, I hadn't taken that first scenario into consideration at
all. So I guess two very aptly named flags would be necessary to
implement this kind of feature...

--
Regards,
Christoph

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

* Re: Why is there no force pull?
  2018-06-09 20:04 ` Elijah Newren
  2018-06-09 20:25   ` Christoph Böhmwalder
@ 2018-06-09 20:30   ` Ævar Arnfjörð Bjarmason
  1 sibling, 0 replies; 5+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2018-06-09 20:30 UTC (permalink / raw)
  To: Elijah Newren; +Cc: Git Mailing List, Christoph Böhmwalder


On Sat, Jun 09 2018, Elijah Newren wrote:

> On Sat, Jun 9, 2018 at 12:01 PM, Christoph Böhmwalder
> <christoph@boehmwalder.at> wrote:
>> Hi,
>>
>> Since this is a use case that actually comes up quite often in
>> day-to-day use, especially among git beginners, I was wondering: is
>> there a specific reason why a command like "fetch changes from remote,
>> overwriting everything in my current working directory including all
>> commits I've made" doesn't exist? Now, I'm quite aware that something
>> like
>>
>>     $ git fetch origin/branch
>>     $ git reset --hard origin/branch
>>
>> will do the trick just fine, but (like I mentioned, especially for
>> beginners) this kind of seems like a crook. Why not have a single
>> command for accomplishing this? Afterall we do have a `--force` flag on
>> `git push`, which practically does the same thing in reverse.
>>
>> Just reaching out to get some input on this, as it seems like a quite
>> curious inconsistency to me.
>
> Upon reading the subject and before reading the body, I assumed you
> were going to ask for a 'git pull --force' that would throw away
> *uncommitted* changes (i.e. do a 'git reset --hard HEAD' before the
> rest of the pull).  But then you asked for both uncommitted and
> committed changes to be thrown away.  That difference isn't something
> you have to consider with a push.
>
> That might be a reason such an option would be confusing, or it might
> just be a warning to document the option carefully.  Anyway, thought
> I'd mention it.

More generally, "git pull"'s params are passed to "git fetch", and then
we either "git merge" or "git rebase".

This proposed behavior doesn't fit into that at all.

But it would if we added a third mode, similar to how we added "rebase",
where we'd dispatch to "reset" instead, so:

    git pull --reset --hard

Meaning (in the general case):

    git fetch &&
    git reset --hard @{u}

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

* Re: Why is there no force pull?
  2018-06-09 19:01 Why is there no force pull? Christoph Böhmwalder
  2018-06-09 20:04 ` Elijah Newren
@ 2018-06-10 16:11 ` Torsten Bögershausen
  1 sibling, 0 replies; 5+ messages in thread
From: Torsten Bögershausen @ 2018-06-10 16:11 UTC (permalink / raw)
  To: git

On Sat, Jun 09, 2018 at 09:01:54PM +0200, Christoph Böhmwalder wrote:
> Hi,
> 
> Since this is a use case that actually comes up quite often in
> day-to-day use, especially among git beginners, I was wondering: is
> there a specific reason why a command like "fetch changes from remote,
> overwriting everything in my current working directory including all
> commits I've made" doesn't exist? Now, I'm quite aware that something
> like
> 
>     $ git fetch origin/branch
>     $ git reset --hard origin/branch

This is not exactly what you askeded for, but I tend not to recommend
people using "git reset --hard" at all.
Either use a "stash", just in case.

Or, in your case:
$ git fetch origin  && git checkout origin/branch

This will put your working tree onto origin/branch.

As a bonus, in case that you have done commits, which are now no longer
visible, "git reflog" is typically able to find them.

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

end of thread, other threads:[~2018-06-10 16:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-09 19:01 Why is there no force pull? Christoph Böhmwalder
2018-06-09 20:04 ` Elijah Newren
2018-06-09 20:25   ` Christoph Böhmwalder
2018-06-09 20:30   ` Ævar Arnfjörð Bjarmason
2018-06-10 16:11 ` Torsten Bögershausen

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).