{"thread":{"id":"24737","subject":"Basic Git usage","startedAt":"2010-08-14T04:32:38Z","lastAt":"2010-08-14T19:41:38Z","messageCount":3,"participants":["hogsolo","Jakub Narebski","Dmitry Potapov"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"148075","messageId":"1281760358285-5422412.post@n2.nabble.com","threadId":"24737","inReplyTo":null,"subject":"Basic Git usage","fromName":"hogsolo","fromEmail":"greg@localdirt.com","sentAt":"2010-08-14T04:32:38Z","receivedAt":"2010-08-14T04:32:38Z","isPatch":false,"sender":{"key":"greg@localdirt.com","avatar":null},"body":"\nHi, Im new to Git, formerly an SVN user.\nI have a master repo and have created a branch. I want to work in both at\nthe same time. I want to change some files in the master, then switch to the\nbranch ( git checkout branchname) , work on some files, then switch back to\nthe master. \nHowever git wont let me switch back to the master until I have added,\ncommitted and pushed my files in the branch. \nIs this correct behavior for git? It would seem that I not be REQUIRED to\ncheck in anything I was working on before switching between branch and\nmaster, but that's the behavior I'm seeing via error messages.\n\nthanks\n\n\n-- \nView this message in context: http://git.661346.n2.nabble.com/Basic-Git-usage-tp5422412p5422412.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"148085","messageId":"m3hbix2wss.fsf@localhost.localdomain","threadId":"24737","inReplyTo":"1281760358285-5422412.post@n2.nabble.com","subject":"Re: Basic Git usage","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-08-14T12:39:16Z","receivedAt":"2010-08-14T12:39:16Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"hogsolo <greg@localdirt.com> writes:\n\n> Hi, Im new to Git, formerly an SVN user.\n>\n> I have a master repo and have created a branch. I want to work in both at\n> the same time. I want to change some files in the master, then switch to the\n> branch ( git checkout branchname) , work on some files, then switch back to\n> the master. \n>\n> However git wont let me switch back to the master until I have added,\n> committed and pushed my files in the branch. \n>\n> Is this correct behavior for git? It would seem that I not be REQUIRED to\n> check in anything I was working on before switching between branch and\n> master, but that's the behavior I'm seeing via error messages.\n\nGit wouldn't allow you to switch a branch ('git checkout <branch>') if\nyou have uncomitted changes that would conflict with the branch you\nswitch to.  For example if you have uncomitted changes to file 'foo',\nand this file is different on the branch you switch to, then git rightly\nrefuses to switch branches.\n\nYou can tell git to try to merge changes with\n\n  git checkout -m <branch>\n\nor you can force git to discard your local changes with\n\n  git checkout -f <branch>\n\nor you can stash away your changes before switching branch.\n\n\nIn no case _pushing_ changes is a requirement.\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"148104","messageId":"AANLkTikQwwyos_xxD2Qvy-z7yjaoEYN-+twHPUKwKfNL@mail.gmail.com","threadId":"24737","inReplyTo":"1281760358285-5422412.post@n2.nabble.com","subject":"Re: Basic Git usage","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2010-08-14T19:41:38Z","receivedAt":"2010-08-14T19:41:38Z","isPatch":false,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"On Sat, Aug 14, 2010 at 8:32 AM, hogsolo <greg@localdirt.com> wrote:\n>\n> I have a master repo and have created a branch. I want to work in both at\n> the same time. I want to change some files in the master, then switch to the\n> branch ( git checkout branchname) , work on some files, then switch back to\n> the master.\n> However git wont let me switch back to the master until I have added,\n> committed and pushed my files in the branch.\n\nIf you have modified files that are different between two branches then\nGit won't allow to switch between them. You have two options:\n- to commit your changes\n- use \"git stash\"\n\nIn contrast to SVN and some other VCS, Git allows you to amend any commit\nlater. To amend the last commit on the current branch, 'git commit --amend'\ncan be used. If you want to modify arbitrary commits, (or squash, or delete\nsome commits) take a look at: \"git rebase --interactive\"\n\nWarning: modifying commits that you published (i.e. made available to\nother users) is in general a bad idea, because it makes difficult for\nother users to work with you.\n\n\nDmitry\n"}]}