{"thread":{"id":"8824","subject":"How to create & switch to a branch after changes have already been made?","startedAt":"2007-07-03T02:18:05Z","lastAt":"2007-07-03T14:04:22Z","messageCount":4,"participants":["Patrick Doyle","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"46312","messageId":"e2a1d0aa0707021918mb335856j278b3128203a793a@mail.gmail.com","threadId":"8824","inReplyTo":null,"subject":"How to create & switch to a branch after changes have already been made?","fromName":"Patrick Doyle","fromEmail":"wpdster@gmail.com","sentAt":"2007-07-03T02:18:05Z","receivedAt":"2007-07-03T02:18:05Z","isPatch":false,"sender":{"key":"wpdster@gmail.com","avatar":null},"body":"Suppose, hypothetically speaking, one were a long time user of CVS who\nconverted to subversion in the last 18 months or so, and who never\nreally understood branches and merging because the syntax was so\nobtuse and because the projects this hypothetical person had worked\nwere short lived enough that (s)he never really needed to create a\nbranch.\n\nNow suppose this hypothetical person was working on a new project,\ndecided to use git as the project's version control system, got\nhalfway through changing a bunch of files, wanted to commit them as\nthey were, since they worked, but were ugly as sin, and wanted to\nclean them up before committing them back to the main line of\ndevelopment.\n\nI would tell that hypothetical person, \"Gee, it sounds like a branch\nis exactly what you need here\".  Unfortunately I don't know how to\ntell the person to do the equivalent of a \"svn switch\" when the local\nrepository has been modified.\n\n$ git branch newbranch\n that works, but\n$ git checkout newbranch\ncomplains that an untracked file would be overwritten by the merge\n(since one of the things that this hypothetical person may have done\nwould have been to do a \"git mv somefile someotherfile\").\n\nWhat would you suggest I say to this person other than \"get in the\nhabit of creating a new branch _any_ time you start something new\".\n\n--wpd\n"},{"id":"46313","messageId":"e2a1d0aa0707021949k181f9042j26ebd124f61ca1ae@mail.gmail.com","threadId":"8824","inReplyTo":"e2a1d0aa0707021918mb335856j278b3128203a793a@mail.gmail.com","subject":"Re: How to create & switch to a branch after changes have already been made?","fromName":"Patrick Doyle","fromEmail":"wpdster@gmail.com","sentAt":"2007-07-03T02:49:47Z","receivedAt":"2007-07-03T02:49:47Z","isPatch":false,"sender":{"key":"wpdster@gmail.com","avatar":null},"body":"Hmmm...\nOne thing I might tell the hypothetical person is to temporarily\ndelete or rename the new version of \"somefile\", so that the merge\ncould complete with problems, and then recreate or rename it back.\nThat would probably allow the hypothetical person to continue his/her\nwork.\n\n--wpd\n"},{"id":"46345","messageId":"Pine.LNX.4.64.0707031210020.4071@racer.site","threadId":"8824","inReplyTo":"e2a1d0aa0707021949k181f9042j26ebd124f61ca1ae@mail.gmail.com","subject":"Re: How to create & switch to a branch after changes have already been made?","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-07-03T11:10:06Z","receivedAt":"2007-07-03T11:10:06Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 2 Jul 2007, Patrick Doyle wrote:\n\n> Hmmm... One thing I might tell the hypothetical person is to temporarily \n> delete or rename the new version of \"somefile\", so that the merge could \n> complete with problems, and then recreate or rename it back. That would \n> probably allow the hypothetical person to continue his/her work.\n\nYou could also say \"git checkout -f newbranch\".\n\nCiao,\nDscho\n"},{"id":"46367","messageId":"e2a1d0aa0707030704r45769fdaw2413a4cad19be935@mail.gmail.com","threadId":"8824","inReplyTo":"Pine.LNX.4.64.0707031210020.4071@racer.site","subject":"Re: How to create & switch to a branch after changes have already been made?","fromName":"Patrick Doyle","fromEmail":"wpdster@gmail.com","sentAt":"2007-07-03T14:04:22Z","receivedAt":"2007-07-03T14:04:22Z","isPatch":false,"sender":{"key":"wpdster@gmail.com","avatar":null},"body":"The real problem was that I did a\n\n$ git-mv somefile somefile.new\n\nand then created a new version of \"somefile\".  When I temporarily\nrenamed it, all of the given suggestions worked.  Thanks.\n\n--wpd\n"}]}