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

Re: fetch and pull

From
Jay Soffian <jaysoffian@gmail.com>
Date
Mar 16, 2009, 22:14 UTC
Message-ID
<76718490903161514ubbdc948o1a0251212fe65fea@mail.gmail.com>
In-Reply-To
<450196A1AAAE4B42A00A8B27A59278E70A2AF023@EXCHANGE.trad.tradestation.com>
On Mon, Mar 16, 2009 at 4:39 PM, John Dlugosz <JDlugosz@tradestation.com> wrote:
> Yes, I do.  If the central repository changed dev in some way other than a fast-forward, or if you really messed up your local dev, it still needs to be repointed.
>
> Remember the overall flow:  first fetch (not pull) and then inspect the difference between your dev and origin/dev.  Then, change your dev to match.

Let me illustrate why this is still probably wrong. I have a clone of git://git.kernel.org/pub/scm/git/git.git. It has the following remote tracking branches:

$ git branch -r
  origin/html
  origin/maint
  origin/man
  origin/master
  origin/next
  origin/pu
  origin/todo

origin/master is never reset. origin/pu resets often. When I want to work on git, I typically create a branch from origin/master. In this case, I would almost never want to reset that branch. So I'd typically do:

$ git checkout -b topic origin/master $ edit, commit, edit, commit... $ git fetch $ git log origin/master..topic $ git rebase origin/master

Rarely, I'll base a topic on origin/pu. And origin/pu might get reset. But even if it were, I wouldn't want to blindly reset my local branch to match, thus losing my local changes. Instead I'd do this:

$ git checkout -b pu-topic origin/pu $ git tag pu-topic-base # handy when origin/pu is reset $ edit, commit, edit, commit $ git fetch drat, origin/pu was reset $ git rebase --onto origin/pu pu-topic-base

And in the rare circumstance that I really do want to reset a local branch, I'd do this:

$ git checkout dev examine, make sure I really want to reset $ git reset --hard origin/dev

I can't really think of a good reason I'd want to reset a local branch which I haven't checked out.

j.
Previous: Sverre RabbelierNext: John Dlugosz
Message 7 of 19 in “Re: fetch and pull”
  1. John DlugoszMar 16, 2009
  2. Jay SoffianMar 16, 2009
  3. John DlugoszMar 16, 2009
  4. Sverre RabbelierMar 16, 2009
  5. Jeff KingMar 17, 2009
  6. Sverre RabbelierMar 17, 2009
  7. Jay SoffianMar 16, 2009
  8. John DlugoszMar 16, 2009
  9. Jay SoffianMar 17, 2009
  10. John DlugoszMar 17, 2009
  11. Jay SoffianMar 17, 2009
  12. John DlugoszMar 17, 2009
  13. Nanako ShiraishiMar 17, 2009
  14. Björn SteinbrinkMar 18, 2009
  15. Junio C HamanoMar 18, 2009
  16. John DlugoszMar 18, 2009
  17. Björn SteinbrinkMar 18, 2009
  18. John DlugoszMar 18, 2009
  19. Jeff KingMar 18, 2009

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.