git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 19, 2008, 07:06 UTC
Message-ID
<7vr6ge9tvh.fsf@gitster.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.
Previous: David SymondsNext: Ping Yin
Message 3 of 10 in “Any command to simplify 'git fetch origin && git reset --hard origin/master'?”
  1. Ping YinJan 19, 2008
  2. David SymondsJan 19, 2008
  3. Junio C HamanoJan 19, 2008
  4. Ping YinJan 19, 2008
  5. Junio C HamanoJan 19, 2008
  6. Ping YinJan 19, 2008
  7. Johannes SchindelinJan 19, 2008
  8. Ping YinJan 19, 2008
  9. Johannes SchindelinJan 19, 2008
  10. Ping YinJan 20, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.