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

How to create & switch to a branch after changes have already been made?

From
PDPatrick Doyle <wpdster@gmail.com>
Date
Jul 3, 2007, 02:18 UTC
Message-ID
<e2a1d0aa0707021918mb335856j278b3128203a793a@mail.gmail.com>

Suppose, hypothetically speaking, one were a long time user of CVS who converted to subversion in the last 18 months or so, and who never really understood branches and merging because the syntax was so obtuse and because the projects this hypothetical person had worked were short lived enough that (s)he never really needed to create a branch.

Now suppose this hypothetical person was working on a new project, decided to use git as the project's version control system, got halfway through changing a bunch of files, wanted to commit them as they were, since they worked, but were ugly as sin, and wanted to clean them up before committing them back to the main line of development.

I would tell that hypothetical person, "Gee, it sounds like a branch is exactly what you need here". Unfortunately I don't know how to tell the person to do the equivalent of a "svn switch" when the local repository has been modified.

$ git branch newbranch
 that works, but
$ git checkout newbranch
complains that an untracked file would be overwritten by the merge
(since one of the things that this hypothetical person may have done
would have been to do a "git mv somefile someotherfile").

What would you suggest I say to this person other than "get in the habit of creating a new branch _any_ time you start something new".

--wpd
Next: Patrick Doyle
Message 1 of 4 in “How to create & switch to a branch after changes have already been made?”
  1. Patrick DoyleJul 3, 2007
  2. Patrick DoyleJul 3, 2007
  3. Johannes SchindelinJul 3, 2007
  4. Patrick DoyleJul 3, 2007

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.