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

Re: [PATCH 1/3] branch: introduce --set-upstream-to

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jul 10, 2012, 21:09 UTC
Message-ID
<20120710210901.GI8439@burratino>
In-Reply-To
<7vsjczgx3h.fsf@alter.siamese.dyndns.org>
Junio C Hamano wrote:
> Jonathan Nieder <jrnieder@gmail.com> writes:
Show 7 quoted lines
>> The immediate problem that seems to trip people up is that it is very
>> tempting to run
>>
>> 	git branch --set-upstream junio/master
>
> I think we have discussed this already a few days ago.  See my
> comment in the earlier thread before this round.
You wrote[*]:
| I think it was a mistake that nobody noticed that it is likely that
| the operation most often will be done for the current branch and the
| usual "give me one branch name to operate on, or I'll operate on the
| current branch" command line convention of "git branch" commannd is
| not a good fit for it, when "set upstream" feature was added
with which I completely agree.  You then moved on to
|                                                               and
[someone should have]
| suggested an alternative syntax that avoids the mistake you quoted
| above, perhaps something like:
|
| 	git branch --set-upstream-to=origin/master [HEAD]
with which I disagree.

As far as I can tell, nobody really thought very hard about what --set-upstream would do when passed only one argument. It should have been made to error out and only later change if someone had an idea about how to make it useful.

Luckily we have a way out. Any example transition plan looks like the following.

DAY 1.
	$ git branch --set-upstream origin/master
	Branch origin/master set up to track local branch debian-sid.
	hint: If you intended to make the current branch track
	hint: origin/master, you can recover with the following commands:
	hint:  $ git branch -d origin/master
	hint:  $ git branch --set-upstream master origin/master
	$
DAY 2.
	$ git branch --set-upstream origin/master
	Branch origin/master set up to track local branch debian-sid.
	warning: using --set-upstream when creating a new branch is deprecated
	hint: use --track instead
	hint:
	hint: If you intended to make the current branch track
	hint: origin/master, you can recover with the following commands:
	hint:  $ git branch -d origin/master
	hint:  $ git branch --set-upstream master origin/master
	$
DAY 3.
	$ git branch --set-upstream origin/master
	fatal: no such branch "origin/master"
	$
DAY 4.
	$ git branch --set-upstream origin/master
	usage: git branch --set-upstream <branchname> <upstream>
	$
[*] http://thread.gmane.org/gmane.comp.version-control.git/201040/focus=201051
Previous: Junio C HamanoNext: Junio C Hamano
Message 9 of 29 in “A better way of handling upstream information in git-branch”
  1. 0/3 A better way of handling upstream information in git-branchCarlos Martín Nieto, Jul 10, 2012
  2. 1/3 branch: introduce --set-upstream-toCarlos Martín Nieto, Jul 10, 2012
  3. Matthieu MoyJul 10, 2012
  4. Junio C HamanoJul 10, 2012
  5. Jonathan NiederJul 10, 2012
  6. Junio C HamanoJul 10, 2012
  7. Jonathan NiederJul 10, 2012
  8. Junio C HamanoJul 10, 2012
  9. Jonathan NiederJul 10, 2012
  10. Junio C HamanoJul 10, 2012
  11. Jonathan NiederJul 10, 2012
  12. Junio C HamanoJul 11, 2012
  13. Jonathan NiederJul 11, 2012
  14. Miles BaderJul 12, 2012
  15. Junio C HamanoJul 12, 2012
  16. 2/3 branch: suggest how to undo a --set-upstream when given one branchCarlos Martín Nieto, Jul 10, 2012
  17. Matthieu MoyJul 10, 2012
  18. Carlos Martín NietoJul 11, 2012
  19. Junio C HamanoJul 10, 2012
  20. Carlos Martín NietoJul 11, 2012
  21. Jonathan NiederJul 10, 2012
  22. Junio C HamanoJul 10, 2012
  23. Jonathan NiederJul 10, 2012
  24. Carlos Martín NietoJul 11, 2012
  25. 3/3 branch: add --unset-upstream optionCarlos Martín Nieto, Jul 10, 2012
  26. Junio C HamanoJul 10, 2012
  27. Carlos Martín NietoJul 11, 2012
  28. Junio C HamanoJul 11, 2012
  29. Carlos Martín NietoJul 12, 2012

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.