# how do you "force a pull"?

7 messages from 2007-08-25 to 2007-08-27. Participants: Jing Xue, Dan Chokola, David Watson, Randal L. Schwartz, Fredrik Tolf.
Thread: https://gitlist.dev/t/9639

## Jing Xue, 2007-08-25 11:19

Subject: how do you "force a pull"?
Message-ID: <20070825111946.GA7122@falcon.digizenstudio.com>
URL: https://gitlist.dev/e/20070825111946.GA7122%40falcon.digizenstudio.com

```
I am working in repo1, and make a savepoint commit and pack up and leave.

On another machine, I have a clone of repo1 (repo2). So I pull from
repo1, "git reset --soft HEAD" to get rid of the savepoint commit, and start working in repo2.

A while later I realize the earlier commit was actually a good commit
point. But I can no longer pull it again from repo1. It keeps giving me
the "Cannot merge" fatal error. "-f" doesn't help.

So in general my question is "how do you force pulling from a remote
repository?"  (short of, you know, recloning the repo...)

I have a feeling that either I'm still stuck in the traditional central-repository
mentality, or missing something real simple.

Thanks.
-- 
Jing Xue

```

## Dan Chokola, 2007-08-25 11:31

Subject: Re: how do you "force a pull"?
Message-ID: <61e816970708250431s1a05a30u992cfcde4f956e85@mail.gmail.com>
URL: https://gitlist.dev/e/61e816970708250431s1a05a30u992cfcde4f956e85%40mail.gmail.com
In-Reply-To: <20070825111946.GA7122@falcon.digizenstudio.com>

```
On 8/25/07, Jing Xue <jingxue@digizenstudio.com> wrote:
> I am working in repo1, and make a savepoint commit and pack up and leave.
>
> On another machine, I have a clone of repo1 (repo2). So I pull from
> repo1, "git reset --soft HEAD" to get rid of the savepoint commit, and start working in repo2.
>
> A while later I realize the earlier commit was actually a good commit
> point. But I can no longer pull it again from repo1. It keeps giving me
> the "Cannot merge" fatal error. "-f" doesn't help.
>
> So in general my question is "how do you force pulling from a remote
> repository?"  (short of, you know, recloning the repo...)
>
> I have a feeling that either I'm still stuck in the traditional central-repository
> mentality, or missing something real simple.
>
> Thanks.
> --
> Jing Xue
> -
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

I've had the same trouble and it also brings up the question, why
can't one fetch into the current branch? To work around git pull's
behavior, I generally either:
- git reset --hard HEAD^^^^^^^ && git pull
 or
- git checkout someotherbranch && git fetch -f origin master

So why doesn't pull -f understand that it should force an update to
the history? And is there some reason I'm missing for why fetch won't
fetch on the current branch?

-- 
Dan Chokola

```

## David Watson, 2007-08-25 11:37

Subject: Re: how do you "force a pull"?
Message-ID: <20070825113747.GA21030@mimvista.com>
URL: https://gitlist.dev/e/20070825113747.GA21030%40mimvista.com
In-Reply-To: <20070825111946.GA7122@falcon.digizenstudio.com>

```
The commit you pulled should still be in your local repository (repo2),
unless you've done something to deliberately remove it.

If you're using the default repository setup when cloning, then master
branch of repo1 should be available as origin/master, so you can do the
following:

$ git reset --hard origin/master

or log:

$ git log origin/master

If you want to see all your branches, local or remote:

$ git branch -r

Note that you shouldn't checkout origin/master and work on it, but rather
you'll want to make a branch, and work on that:

$ git co -b fancy_branch origin/master

You may be getting the "cannot merge message" if you have uncommitted
changes, as git won't let you merge when the working copy is changed.
git-pull is really git-fetch + git-merge.

On Sat, Aug 25, 2007 at 07:19:46AM -0400, Jing Xue wrote:
> I am working in repo1, and make a savepoint commit and pack up and leave.
> 
> On another machine, I have a clone of repo1 (repo2). So I pull from
> repo1, "git reset --soft HEAD" to get rid of the savepoint commit, and start working in repo2.
> 
> A while later I realize the earlier commit was actually a good commit
> point. But I can no longer pull it again from repo1. It keeps giving me
> the "Cannot merge" fatal error. "-f" doesn't help.
> 
> So in general my question is "how do you force pulling from a remote
> repository?"  (short of, you know, recloning the repo...)
> 
> I have a feeling that either I'm still stuck in the traditional central-repository
> mentality, or missing something real simple.
> 
> Thanks.
> -- 
> Jing Xue
> -
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Dave Watson

```

## Jing Xue, 2007-08-25 11:53

Subject: Re: how do you "force a pull"?
Message-ID: <20070825115326.GB7122@falcon.digizenstudio.com>
URL: https://gitlist.dev/e/20070825115326.GB7122%40falcon.digizenstudio.com
In-Reply-To: <20070825113747.GA21030@mimvista.com>

```
On Sat, Aug 25, 2007 at 07:37:47AM -0400, David Watson wrote:
> $ git reset --hard origin/master

Ah, this is what I was looking for. Not very intuitive, but works like a
charm!

> You may be getting the "cannot merge message" if you have uncommitted
> changes, as git won't let you merge when the working copy is changed.
> git-pull is really git-fetch + git-merge.

Right, because I used "--soft" in the earlier reset.

Thanks!
-- 
Jing Xue

```

## Randal L. Schwartz, 2007-08-25 13:19

Subject: Re: how do you "force a pull"?
Message-ID: <86odgveoq4.fsf@blue.stonehenge.com>
URL: https://gitlist.dev/e/86odgveoq4.fsf%40blue.stonehenge.com
In-Reply-To: <20070825115326.GB7122@falcon.digizenstudio.com>

```
>>>>> "Jing" == Jing Xue <jingxue@digizenstudio.com> writes:

Jing> Ah, this is what I was looking for. Not very intuitive, but works like a
Jing> charm!

I find the word "intuitive" is like "common sense", which apparently isn't
very common. :)

"Not very intuitive" can be translated as "I don't yet share the mental model
from which this observation would be obvious".

I would suggest that to make such observations more intuitive, you stop
thinking of git as you would SVN or (gasp!) CVS, and start paying attention to
what git-fetch is really doing to the local object tree, and git-merge on top
of that, collectively known as git-pull.

The concept of keeping track of a directed graph of commits is not present in
"classic" source code managers... and once you make the mental leap, you'll
wonder why it was ever done differently.  It's revolutionary, not just
evolutionary.

(And if this sounds meta, it's because I'm rewriting my "intro to git" slides
because I just confirmed where my next presentation will be, and want them to
be even better.)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

```

## Fredrik Tolf, 2007-08-26 19:02

Subject: Re: how do you "force a pull"?
Message-ID: <m34pimdspt.fsf@pc7.dolda2000.com>
URL: https://gitlist.dev/e/m34pimdspt.fsf%40pc7.dolda2000.com
In-Reply-To: <20070825111946.GA7122@falcon.digizenstudio.com>

```
Jing Xue <jingxue@digizenstudio.com> writes:

> I am working in repo1, and make a savepoint commit and pack up and leave.
>
> On another machine, I have a clone of repo1 (repo2). So I pull from
> repo1, "git reset --soft HEAD" to get rid of the savepoint commit, and start working in repo2.
>
> A while later I realize the earlier commit was actually a good commit
> point. But I can no longer pull it again from repo1. It keeps giving me
> the "Cannot merge" fatal error. "-f" doesn't help.

This is probably not as good an answer as David Watson's suggestion,
but if what you want is to commit your current code while still having
your savepoint commit in the history, shouldn't you be able to commit
your current code and then use git-rebase to rebase it onto the
savepoint commit?

Fredrik Tolf

```

## Jing Xue, 2007-08-27 05:26

Subject: Re: how do you "force a pull"?
Message-ID: <20070827052631.GA3580@falcon.digizenstudio.com>
URL: https://gitlist.dev/e/20070827052631.GA3580%40falcon.digizenstudio.com
In-Reply-To: <m34pimdspt.fsf@pc7.dolda2000.com>

```
On Sun, Aug 26, 2007 at 09:02:54PM +0200, Fredrik Tolf wrote:
> 
> This is probably not as good an answer as David Watson's suggestion,
> but if what you want is to commit your current code while still having
> your savepoint commit in the history, shouldn't you be able to commit
> your current code and then use git-rebase to rebase it onto the
> savepoint commit?

Yep, I tried and it works too. A bit more verbose than a hard reset -
involved some manual merging in my case, had to update-index and then
--continue the rebase. But then I think this approach is semantically
different and probably safer than a hard reset in some cases.

All this is interesting and good to know. Thanks, Fredrik!
-- 
Jing Xue

```
