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

Re: [PATCH] pull, fetch: add --set-upstream option

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 19, 2019, 20:04 UTC
Message-ID
<xmqq1rxgyl99.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<86blwlcylf.fsf@matthieu-moy.fr>
Matthieu Moy <Matthieu.Moy@matthieu-moy.fr> writes:
Show 13 quoted lines
> To me, it depends on the involvement in the project. If I plan to send
> several contributions to a project, I'd usually clone the upstream and
> add my fork. But I also often do:
>
> - Find a project on GitHub/GitLab/...
> - Think about a minor contribution I can make
> - Fork from the web UI
> - clone my fork
> - code, commit, push
> - make a PR
>
> Only if my PR takes time to get accepted, I'll add upstream as a remote
> and pull from there to rebase my PR.
OK.
Show 11 quoted lines
>>  - The second step adds the true upstream using "git remote", and at
>>    that point, in your mind you are quite clear that you want to
>>    pull from there (and push to your own fork).  Not having the "I
>>    am adding this new remote; from now on, it is my upstream"
>
> Note that you can also group "remote add" and "pull" by saying just
>
>   git pull --set-upstream http://example.com/project-main-repo master
>
> (I still tend to prefer the "remote add" + "pull" flow to name the
> remote, though).

I do too, and that's where my "shouldn't this feature be part of 'remote add' comes from.

Show 14 quoted lines
> That wouldn't make the commands really easier to type IMHO, as you would
> still have to pull at some point, so it's:
>
>   git remote add main http://example.com/project-main-repo
>   git pull --set-upstream main master
>   
> Vs
>
>   git remote add --set-upstream master main http://example.com/project-main-repo
>   git pull
>
> The second is a bit shorter (saves the second instance of "master"), but
> I tend to prefer the first to avoid the overly long "git remote add"
> command.

I do not particularly care about five extra keystrokes. The reason I prefer the latter more is conceptual clarity of it saying "I use 'remote' to set things up, and then use 'pull' to get updated" (as opposed to "I use 'remote' to set things half-way up, and then use the first 'pull' to finish setting things up and getting updated. I should remember that I do not need to give --set-upstream to later 'pull' I used to get further updates").

Show 5 quoted lines
> Actually, since "--set-upstream" means "next time, *pull* from this
> branch", it felt weird to have it in "git *push*" and not in "git pull".
> Certainly, not having "git pull --set-upstream" it "git pull" wasn't
> that much bothering (otherwise, someone would have implemented it long
> ago), but I still find it a nice-to-have shortcut.

Yeah, I do not think 'push --set-upstream' is a great feature, either, but since we have it already, I do not mind too much to have another on the 'pull' side. It just feels that we are piling band aid for the lack of the right feature in the right command by adding it to wrong command(s).

Previous: Matthieu MoyNext: Matthieu Moy
Message 18 of 19 in “Re: [PATCH] [WIP/RFC] add git pull and git fetch --set-upstream”
  1. Matthieu MoyApr 4, 2019
  2. Corentin BOMPARDApr 9, 2019
  3. [WIP/RFC] add git pull and git fetch --set-upstreamCorentin BOMPARD, Apr 17, 2019
  4. Junio C HamanoApr 18, 2019
  5. Corentin BOMPARDApr 19, 2019
  6. [WIP/RFC] add git pull and git fetch --set-upstreamCorentin BOMPARD, Apr 19, 2019
  7. Matthieu MoyApr 18, 2019
  8. Junio C HamanoApr 19, 2019
  9. Matthieu MoyApr 18, 2019
  10. Matthieu MoyApr 19, 2019
  11. Matthieu MoyApr 22, 2019
  12. pull, fetch: add --set-upstream optionMatthieu Moy, Aug 14, 2019
  13. Pratyush YadavAug 14, 2019
  14. Matthieu MoyAug 19, 2019
  15. pull, fetch: add --set-upstream optionMatthieu Moy, Aug 19, 2019
  16. Junio C HamanoAug 14, 2019
  17. Matthieu MoyAug 19, 2019
  18. Junio C HamanoAug 19, 2019
  19. Matthieu MoyAug 20, 2019

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.