git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Any command to simplify 'git fetch origin && git reset --hard origin/master'?
@ 2008-01-19  5:22 Ping Yin
  2008-01-19  6:04 ` David Symonds
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Ping Yin @ 2008-01-19  5:22 UTC (permalink / raw)
  To: Git Mailing List

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

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

* Re: Any command to simplify 'git fetch origin && git reset --hard origin/master'?
  2008-01-19  5:22 Any command to simplify 'git fetch origin && git reset --hard origin/master'? Ping Yin
@ 2008-01-19  6:04 ` David Symonds
  2008-01-19  7:06 ` Junio C Hamano
  2008-01-19 11:15 ` Johannes Schindelin
  2 siblings, 0 replies; 10+ messages in thread
From: David Symonds @ 2008-01-19  6:04 UTC (permalink / raw)
  To: Ping Yin; +Cc: Git Mailing List

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.

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

* Re: Any command to simplify 'git fetch origin && git reset --hard origin/master'?
  2008-01-19  5:22 Any command to simplify 'git fetch origin && git reset --hard origin/master'? Ping Yin
  2008-01-19  6:04 ` David Symonds
@ 2008-01-19  7:06 ` Junio C Hamano
  2008-01-19  8:03   ` Ping Yin
  2008-01-19 11:15 ` Johannes Schindelin
  2 siblings, 1 reply; 10+ messages in thread
From: Junio C Hamano @ 2008-01-19  7:06 UTC (permalink / raw)
  To: Ping Yin; +Cc: Git Mailing List

"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.

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

* Re: Any command to simplify 'git fetch origin && git reset --hard origin/master'?
  2008-01-19  7:06 ` Junio C Hamano
@ 2008-01-19  8:03   ` Ping Yin
  2008-01-19  8:06     ` Junio C Hamano
  0 siblings, 1 reply; 10+ messages in thread
From: Ping Yin @ 2008-01-19  8:03 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List

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

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

* Re: Any command to simplify 'git fetch origin && git reset --hard origin/master'?
  2008-01-19  8:03   ` Ping Yin
@ 2008-01-19  8:06     ` Junio C Hamano
  2008-01-19  8:08       ` Ping Yin
  0 siblings, 1 reply; 10+ messages in thread
From: Junio C Hamano @ 2008-01-19  8:06 UTC (permalink / raw)
  To: Ping Yin; +Cc: Junio C Hamano, Git Mailing List

"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".

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

* Re: Any command to simplify 'git fetch origin && git reset --hard origin/master'?
  2008-01-19  8:06     ` Junio C Hamano
@ 2008-01-19  8:08       ` Ping Yin
  0 siblings, 0 replies; 10+ messages in thread
From: Ping Yin @ 2008-01-19  8:08 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List

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

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

* Re: Any command to simplify 'git fetch origin && git reset --hard origin/master'?
  2008-01-19  5:22 Any command to simplify 'git fetch origin && git reset --hard origin/master'? Ping Yin
  2008-01-19  6:04 ` David Symonds
  2008-01-19  7:06 ` Junio C Hamano
@ 2008-01-19 11:15 ` Johannes Schindelin
  2008-01-19 14:03   ` Ping Yin
  2 siblings, 1 reply; 10+ messages in thread
From: Johannes Schindelin @ 2008-01-19 11:15 UTC (permalink / raw)
  To: Ping Yin; +Cc: Git Mailing List

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

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

* Re: Any command to simplify 'git fetch origin && git reset --hard origin/master'?
  2008-01-19 11:15 ` Johannes Schindelin
@ 2008-01-19 14:03   ` Ping Yin
  2008-01-19 22:50     ` Johannes Schindelin
  0 siblings, 1 reply; 10+ messages in thread
From: Ping Yin @ 2008-01-19 14:03 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Git Mailing List

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

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

* Re: Any command to simplify 'git fetch origin && git reset --hard origin/master'?
  2008-01-19 14:03   ` Ping Yin
@ 2008-01-19 22:50     ` Johannes Schindelin
  2008-01-20  8:51       ` Ping Yin
  0 siblings, 1 reply; 10+ messages in thread
From: Johannes Schindelin @ 2008-01-19 22:50 UTC (permalink / raw)
  To: Ping Yin; +Cc: Git Mailing List

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

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

* Re: Any command to simplify 'git fetch origin && git reset --hard origin/master'?
  2008-01-19 22:50     ` Johannes Schindelin
@ 2008-01-20  8:51       ` Ping Yin
  0 siblings, 0 replies; 10+ messages in thread
From: Ping Yin @ 2008-01-20  8:51 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Git Mailing List

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

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

end of thread, other threads:[~2008-01-20  8:51 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-19  5:22 Any command to simplify 'git fetch origin && git reset --hard origin/master'? Ping Yin
2008-01-19  6:04 ` David Symonds
2008-01-19  7:06 ` Junio C Hamano
2008-01-19  8:03   ` Ping Yin
2008-01-19  8:06     ` Junio C Hamano
2008-01-19  8:08       ` Ping Yin
2008-01-19 11:15 ` Johannes Schindelin
2008-01-19 14:03   ` Ping Yin
2008-01-19 22:50     ` Johannes Schindelin
2008-01-20  8:51       ` Ping Yin

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 NNTP newsgroup(s).