# Any command to simplify 'git fetch origin && git reset --hard origin/master'?

10 messages from 2008-01-19 to 2008-01-20. Participants: Ping Yin, David Symonds, Junio C Hamano, Johannes Schindelin.
Thread: https://gitlist.dev/t/11672

## Ping Yin, 2008-01-19 05:22

Subject: Any command to simplify 'git fetch origin && git reset --hard origin/master'?
Message-ID: <46dff0320801182122t1581b366yad123407aaad6326@mail.gmail.com>
URL: https://gitlist.dev/e/46dff0320801182122t1581b366yad123407aaad6326%40mail.gmail.com

```
I often encounter the case that the origin reposotory is rebased and i
make sure i want to use the origin head as my master
Now I have to do
$ git fetch origin && git reset --hard origin/master

Should we introduce 'git pull --force-update' or something else to do
the command combination?

-- 
Ping Yin

```

## David Symonds, 2008-01-19 06:04

Subject: Re: Any command to simplify 'git fetch origin && git reset --hard origin/master'?
Message-ID: <ee77f5c20801182204r53ae03c2mac6d8fde9c4b260a@mail.gmail.com>
URL: https://gitlist.dev/e/ee77f5c20801182204r53ae03c2mac6d8fde9c4b260a%40mail.gmail.com
In-Reply-To: <46dff0320801182122t1581b366yad123407aaad6326@mail.gmail.com>

```
On Jan 19, 2008 4:22 PM, Ping Yin <pkufranky@gmail.com> wrote:
> I often encounter the case that the origin reposotory is rebased and i
> make sure i want to use the origin head as my master
> Now I have to do
> $ git fetch origin && git reset --hard origin/master

Use "git pull origin", which will do the fetch, and then merge it. If
you haven't made local changes, the merge will be a fast-forward and
so will get you an equivalent result.


Dave.

```

## Junio C Hamano, 2008-01-19 07:06

Subject: Re: Any command to simplify 'git fetch origin && git reset --hard origin/master'?
Message-ID: <7vr6ge9tvh.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vr6ge9tvh.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <46dff0320801182122t1581b366yad123407aaad6326@mail.gmail.com>

```
"Ping Yin" <pkufranky@gmail.com> writes:

> I often encounter the case that the origin reposotory is rebased and i
> make sure i want to use the origin head as my master
> Now I have to do
> $ git fetch origin && git reset --hard origin/master

The fact you are resetting means you do not have anything
interesting in your own branch yourself (--hard will lose your
changes and you are willing to lose it), which makes the use
case much less interesting, but I can understand a workflow that
is based around rebases, as in:

	$ git fetch origin && git rebase origin/master

which would be an equivalent to the resetting --hard when you do
not have anything interesting in your branch but if you do have
interesting commits they will be transplanted on top of the
rebased upstream head.

Upcoming 1.5.4 will have "git pull --rebase origin", which is a
short-hand for the above command.  That is a parallel for rebase
based workflow, just like "git pull origin" is a short-hand for

	$ git fetch origin && git merge origin/master

to help merge based workflow.

```

## Ping Yin, 2008-01-19 08:03

Subject: Re: Any command to simplify 'git fetch origin && git reset --hard origin/master'?
Message-ID: <46dff0320801190003x622a4f81j1c156f346f5bac03@mail.gmail.com>
URL: https://gitlist.dev/e/46dff0320801190003x622a4f81j1c156f346f5bac03%40mail.gmail.com
In-Reply-To: <7vr6ge9tvh.fsf@gitster.siamese.dyndns.org>

```
On Jan 19, 2008 3:06 PM, Junio C Hamano <gitster@pobox.com> wrote:
> "Ping Yin" <pkufranky@gmail.com> writes:
>
> > I often encounter the case that the origin reposotory is rebased and i
> > make sure i want to use the origin head as my master
> > Now I have to do
> > $ git fetch origin && git reset --hard origin/master
>
> The fact you are resetting means you do not have anything
> interesting in your own branch yourself (--hard will lose your
> changes and you are willing to lose it), which makes the use
> case much less interesting, but I can understand a workflow that
> is based around rebases, as in:
>
>         $ git fetch origin && git rebase origin/master
>
I know 'git pull --rebase' and use it frequently. However, in the case
i mentioned above, i never do any change in this local branch, i just
use this branch for deployment which should always keep the same with
the origin head (just like the remote tracking branch). So i need a
'fetch & reset --hard' equivalent, not the 'fetch & rebase'
equivalent.




-- 
Ping Yin

```

## Junio C Hamano, 2008-01-19 08:06

Subject: Re: Any command to simplify 'git fetch origin && git reset --hard origin/master'?
Message-ID: <7vbq7i9r48.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vbq7i9r48.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <46dff0320801190003x622a4f81j1c156f346f5bac03@mail.gmail.com>

```
"Ping Yin" <pkufranky@gmail.com> writes:

> On Jan 19, 2008 3:06 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> "Ping Yin" <pkufranky@gmail.com> writes:
>>
>> > I often encounter the case that the origin reposotory is rebased and i
>> > make sure i want to use the origin head as my master
>> > Now I have to do
>> > $ git fetch origin && git reset --hard origin/master
>>
>> The fact you are resetting means you do not have anything
>> interesting in your own branch yourself (--hard will lose your
>> changes and you are willing to lose it), which makes the use
>> case much less interesting, but I can understand a workflow that
>> is based around rebases, as in:
>>
>>         $ git fetch origin && git rebase origin/master
>>
> I know 'git pull --rebase' and use it frequently. However, in the case
> i mentioned above, i never do any change in this local branch, i just
> use this branch for deployment which should always keep the same with
> the origin head (just like the remote tracking branch). So i need a
> 'fetch & reset --hard' equivalent, not the 'fetch & rebase'
> equivalent.

Unless I am misreading you, you did not read what I wrote.

If you do not have any change on that branch, "git rebase
origin/master" will be equivalent to "git reset --hard
origin/master".

```

## Ping Yin, 2008-01-19 08:08

Subject: Re: Any command to simplify 'git fetch origin && git reset --hard origin/master'?
Message-ID: <46dff0320801190008p4489b7a2g6153ba7d30f942c3@mail.gmail.com>
URL: https://gitlist.dev/e/46dff0320801190008p4489b7a2g6153ba7d30f942c3%40mail.gmail.com
In-Reply-To: <7vbq7i9r48.fsf@gitster.siamese.dyndns.org>

```
On Jan 19, 2008 4:06 PM, Junio C Hamano <gitster@pobox.com> wrote:
>
> "Ping Yin" <pkufranky@gmail.com> writes:
>
> > On Jan 19, 2008 3:06 PM, Junio C Hamano <gitster@pobox.com> wrote:
> >> "Ping Yin" <pkufranky@gmail.com> writes:
> >>
> >> > I often encounter the case that the origin reposotory is rebased and i
> >> > make sure i want to use the origin head as my master
> >> > Now I have to do
> >> > $ git fetch origin && git reset --hard origin/master
> >>
> >> The fact you are resetting means you do not have anything
> >> interesting in your own branch yourself (--hard will lose your
> >> changes and you are willing to lose it), which makes the use
> >> case much less interesting, but I can understand a workflow that
> >> is based around rebases, as in:
> >>
> >>         $ git fetch origin && git rebase origin/master
> >>
> > I know 'git pull --rebase' and use it frequently. However, in the case
> > i mentioned above, i never do any change in this local branch, i just
> > use this branch for deployment which should always keep the same with
> > the origin head (just like the remote tracking branch). So i need a
> > 'fetch & reset --hard' equivalent, not the 'fetch & rebase'
> > equivalent.
>
> Unless I am misreading you, you did not read what I wrote.
>
> If you do not have any change on that branch, "git rebase
> origin/master" will be equivalent to "git reset --hard
> origin/master".
>
But my case is that the origin head has been rewound.



-- 
Ping Yin

```

## Johannes Schindelin, 2008-01-19 11:15

Subject: Re: Any command to simplify 'git fetch origin && git reset --hard origin/master'?
Message-ID: <alpine.LSU.1.00.0801191114310.5731@racer.site>
URL: https://gitlist.dev/e/alpine.LSU.1.00.0801191114310.5731%40racer.site
In-Reply-To: <46dff0320801182122t1581b366yad123407aaad6326@mail.gmail.com>

```
Hi,

On Sat, 19 Jan 2008, Ping Yin wrote:

> I often encounter the case that the origin reposotory is rebased and i
> make sure i want to use the origin head as my master
> Now I have to do
> $ git fetch origin && git reset --hard origin/master

Just make an alias if you're too lazy to type.

Personally, I do not see much sense in it, and it is too dangerous to 
bless it with an option to fetch or pull.

Ciao,
Dscho

```

## Ping Yin, 2008-01-19 14:03

Subject: Re: Any command to simplify 'git fetch origin && git reset --hard origin/master'?
Message-ID: <46dff0320801190603w4f0b2595v495ed10f2a87b0cc@mail.gmail.com>
URL: https://gitlist.dev/e/46dff0320801190603w4f0b2595v495ed10f2a87b0cc%40mail.gmail.com
In-Reply-To: <alpine.LSU.1.00.0801191114310.5731@racer.site>

```
On Jan 19, 2008 7:15 PM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> Hi,
>
> On Sat, 19 Jan 2008, Ping Yin wrote:
>
> > I often encounter the case that the origin reposotory is rebased and i
> > make sure i want to use the origin head as my master
> > Now I have to do
> > $ git fetch origin && git reset --hard origin/master
>
> Just make an alias if you're too lazy to type.
>
> Personally, I do not see much sense in it, and it is too dangerous to
> bless it with an option to fetch or pull.
>
Can any alias do this? Since a parameter 'origin' or something should
be passed in.
Of course i can write a very simple wrapper. I just try to figure out
the better way.
> Ciao,
> Dscho
>
>



-- 
Ping Yin

```

## Johannes Schindelin, 2008-01-19 22:50

Subject: Re: Any command to simplify 'git fetch origin && git reset --hard origin/master'?
Message-ID: <alpine.LSU.1.00.0801192247280.5731@racer.site>
URL: https://gitlist.dev/e/alpine.LSU.1.00.0801192247280.5731%40racer.site
In-Reply-To: <46dff0320801190603w4f0b2595v495ed10f2a87b0cc@mail.gmail.com>

```
Hi,

On Sat, 19 Jan 2008, Ping Yin wrote:

> On Jan 19, 2008 7:15 PM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
>
> > On Sat, 19 Jan 2008, Ping Yin wrote:
> >
> > > I often encounter the case that the origin reposotory is rebased and 
> > > i make sure i want to use the origin head as my master Now I have to 
> > > do
> > >	$ git fetch origin && git reset --hard origin/master
> >
> > Just make an alias if you're too lazy to type.
> >
> > Personally, I do not see much sense in it, and it is too dangerous to 
> > bless it with an option to fetch or pull.
>
> Can any alias do this? Since a parameter 'origin' or something should be 
> passed in.

Yes.  Something like

	$ git config alias.imtoolazytotype \
		'!sh -c "git fetch $0 && git reset --hard $0/master"'

See http://git.or.cz/gitwiki/Aliases for more, especially the part about 
advanced aliases with arguments.

Hth,
Dscho

```

## Ping Yin, 2008-01-20 08:51

Subject: Re: Any command to simplify 'git fetch origin && git reset --hard origin/master'?
Message-ID: <46dff0320801200051p4dd21930u5712a72baaf9af78@mail.gmail.com>
URL: https://gitlist.dev/e/46dff0320801200051p4dd21930u5712a72baaf9af78%40mail.gmail.com
In-Reply-To: <alpine.LSU.1.00.0801192247280.5731@racer.site>

```
On Jan 20, 2008 6:50 AM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> Hi,
>
> On Sat, 19 Jan 2008, Ping Yin wrote:
>
> > On Jan 19, 2008 7:15 PM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> >
> > > On Sat, 19 Jan 2008, Ping Yin wrote:
> > >
> > > > I often encounter the case that the origin reposotory is rebased and
> > > > i make sure i want to use the origin head as my master Now I have to
> > > > do
> > > >   $ git fetch origin && git reset --hard origin/master
> > >
> > > Just make an alias if you're too lazy to type.
> > >
> > > Personally, I do not see much sense in it, and it is too dangerous to
> > > bless it with an option to fetch or pull.
> >
> > Can any alias do this? Since a parameter 'origin' or something should be
> > passed in.
>
> Yes.  Something like
>
>         $ git config alias.imtoolazytotype \
>                 '!sh -c "git fetch $0 && git reset --hard $0/master"'
>
> See http://git.or.cz/gitwiki/Aliases for more, especially the part about
> advanced aliases with arguments.
>
wonderful!
> Hth,
> Dscho
>
>



-- 
Ping Yin

```
