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

bug during checkout of remote branch and uncommited changes ?

From
Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Date
Jul 7, 2017, 12:37 UTC
Message-ID
<20170707123727.dgd5rub2ycrg525y@ltop.local>
Hi,

Lately I've been caught several time with a problem which, to me, is a bug. It can easily be reproduced, so I think It's very possible it has already been reported.

The problem arise when trying to checkout a branch while having
some uncommited changes. The scenario is the following:
	$ git status
	M  afile.c
	$ git remote add <aremote> <anurl> 
	$ git fetch <aremote> <abranch>
	remote: Counting objects: 7, done.
	remote: Compressing objects: 100% (6/6), done.
	remote: Total 7 (delta 5), reused 3 (delta 1)
	Unpacking objects: 100% (7/7), done.
	From <anurl>
	 * branch                <abranch> -> FETCH_HEAD
	 * [new branch]          <abranch> -> <aremote>/<abranch>
	$ git co <abranch>
	error: Your local changes to the following files would be overwritten by checkout:
		afile.c
	Please commit your changes or stash them before you switch branches.
	Aborting
	$ git reset --hard
	patching file afile.c
	$ git co <abranch>
	fatal: Not tracking: ambiguous information for ref refs/remotes/<aremote>/<abranch>
What can be ambiguous here?
Strangely, trying a second time, succeed:
	$ git co <abranch>
	Previous HEAD position was ...
	Switched to branch '<abranch>'
-- Luc Van Oostenryck
Next: Junio C Hamano
Message 1 of 5 in “bug during checkout of remote branch and uncommited changes ?”
  1. Luc Van OostenryckJul 7, 2017
  2. Junio C HamanoJul 7, 2017
  3. Luc Van OostenryckJul 7, 2017
  4. Junio C HamanoJul 7, 2017
  5. Luc Van OostenryckJul 7, 2017

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.