{"thread":{"id":"19638","subject":"Duplicating a branch","startedAt":"2009-06-02T15:19:36Z","lastAt":"2009-06-02T16:50:09Z","messageCount":3,"participants":["Aaron Gray","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"115250","messageId":"BAF61FDE71D344FDB9F1415B5E2AFD75@HPLAPTOP","threadId":"19638","inReplyTo":null,"subject":"Duplicating a branch","fromName":"Aaron Gray","fromEmail":"aaronngray.lists@googlemail.com","sentAt":"2009-06-02T15:19:36Z","receivedAt":"2009-06-02T15:19:36Z","isPatch":false,"sender":{"key":"aaronngray.lists@googlemail.com","avatar":null},"body":"Hi,\n\nHow do I go about duplicating a branch within a repository, so I can make \ntest mods ?\n\nMany thanks in advance,\n\nAaron \n"},{"id":"115255","messageId":"7voct6fy1e.fsf@alter.siamese.dyndns.org","threadId":"19638","inReplyTo":"BAF61FDE71D344FDB9F1415B5E2AFD75@HPLAPTOP","subject":"Re: Duplicating a branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-06-02T15:36:13Z","receivedAt":"2009-06-02T15:36:13Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Aaron Gray\" <aaronngray.lists@googlemail.com> writes:\n\n> How do I go about duplicating a branch within a repository, so I can\n> make test mods ?\n\nRun\n\n    $ git checkout -b experiment master\n\nto make a new \"experiment\" branch that points at the same comit as\n\"master\" (or whatever other branch), hack away (including committing which\nwould grow the history of \"experiment\" branch without touching \"master\").\n\nAfter you are done, and if you want to discard it, simply:\n\n    $ git checkout master\n    $ git branch -D experiment\n\nor if you want to keep all of it:\n\n    $ git checkout master\n    $ git merge experiment\n\n*BUT* if your \"experiment\" was truly exploratory in the sense that your\nhistory is full of \"let's try this, commit to snapshot, test, oops, it did\nnot work, let's try that, commit to snapshot, test, ok, I made some\nprogress, let's continue\" crufts, you would most likely want to clean-up\nyour history before the latter \"checkout master and merge experiment into\nit\" steps with something like:\n\n    $ git rebase -i master experiment\n\nIf you in advance know that what you are going to do is truly \"throw-away\nexperiment\", you do not even need to use an \"experiment\" branch.  You can\ndo your exploration while on a detached HEAD:\n\n    $ git checkout master^0\n\nand hack away, including making commits (but you will discard them in\nthe end), and then finally:\n\n    $ git reset --hard ;# if you have local changes you do not want to\n\t\t\t  take back to master\n    $ git checkout master\n\n\n\n    \n"},{"id":"115261","messageId":"70411981D37A4F2ABF5D0A9CF24E6884@HPLAPTOP","threadId":"19638","inReplyTo":"7voct6fy1e.fsf@alter.siamese.dyndns.org","subject":"Re: Duplicating a branch","fromName":"Aaron Gray","fromEmail":"aaronngray.lists@googlemail.com","sentAt":"2009-06-02T16:50:09Z","receivedAt":"2009-06-02T16:50:09Z","isPatch":false,"sender":{"key":"aaronngray.lists@googlemail.com","avatar":null},"body":"Nice expanation and mini tutoial Junio !\n\nThanks ever so much, very useful.\n\nAaron\n\n> \"Aaron Gray\" <aaronngray.lists@googlemail.com> writes:\n>\n>> How do I go about duplicating a branch within a repository, so I can\n>> make test mods ?\n>\n> Run\n>\n>    $ git checkout -b experiment master\n>\n> to make a new \"experiment\" branch that points at the same comit as\n> \"master\" (or whatever other branch), hack away (including committing which\n> would grow the history of \"experiment\" branch without touching \"master\").\n>\n> After you are done, and if you want to discard it, simply:\n>\n>    $ git checkout master\n>    $ git branch -D experiment\n>\n> or if you want to keep all of it:\n>\n>    $ git checkout master\n>    $ git merge experiment\n>\n> *BUT* if your \"experiment\" was truly exploratory in the sense that your\n> history is full of \"let's try this, commit to snapshot, test, oops, it did\n> not work, let's try that, commit to snapshot, test, ok, I made some\n> progress, let's continue\" crufts, you would most likely want to clean-up\n> your history before the latter \"checkout master and merge experiment into\n> it\" steps with something like:\n>\n>    $ git rebase -i master experiment\n>\n> If you in advance know that what you are going to do is truly \"throw-away\n> experiment\", you do not even need to use an \"experiment\" branch.  You can\n> do your exploration while on a detached HEAD:\n>\n>    $ git checkout master^0\n>\n> and hack away, including making commits (but you will discard them in\n> the end), and then finally:\n>\n>    $ git reset --hard ;# if you have local changes you do not want to\n>   take back to master\n>    $ git checkout master\n>\n>\n>\n> \n"}]}