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

Re: Switching between branches

From
Petr Baudis <pasky@ucw.cz>
Date
Apr 21, 2005, 07:31 UTC
Message-ID
<20050421073123.GD31910@pasky.ji.cz>
In-Reply-To
<1114047759.20044.22.camel@dv>

Dear diary, on Thu, Apr 21, 2005 at 03:42:39AM CEST, I got a letter where Pavel Roskin <proski@gnu.org> told me that...

> Hello!
Hello,
> Perhaps it's a naive question, but how do I switch between branches?  I
> mean an equivalent of "svn switch" or "cvs update -r branch" that would
> reuse the existing working directory.

you can't. There was 'git update' (and intermediate never-committed 'git switch'), but I decided not to support it for now, since I don't have any compelling usage case for it. Do

	git fork my-linus ~/my-linus linus

and you will get a local clone of Linus' branch in ~/my-linus, tracking and everything.

> Then I tried "git merge -b pasky linus" - this actually changed the
> files to the linus branch, but it didn't remove files specific to
> git-pasky.  Also, I'm surprised that I had to specify "-b pasky", as if
> the currently checked out branch is unknown.

Since git merge's purpose is to _merge_, not _switch_, so it picks the common ancestor by default; another disadvantage is that this happens on top of your local tree, but your history will record it as a merge which shares both linus and my history, which isn't quite right. What is peculiar, though, is that it didn't remove the files specific to git-pasky.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
Previous: Pavel RoskinNext: Matthias Urlichs
Message 2 of 4 in “Switching between branches”
  1. Pavel RoskinApr 21, 2005
  2. Petr BaudisApr 21, 2005
  3. Matthias UrlichsApr 21, 2005
  4. Petr BaudisApr 21, 2005

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.