{"thread":{"id":"24135","subject":"unable to checkout branches and proper procedure for creating a new branch based off of another one","startedAt":"2010-06-17T02:41:23Z","lastAt":"2010-06-17T05:04:26Z","messageCount":4,"participants":["Thomas Anderson","Gabriel Filion"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"143844","messageId":"AANLkTilZ6zoByCngAGoCbgQ9yd424VcChpTKh_XLnogd@mail.gmail.com","threadId":"24135","inReplyTo":null,"subject":"unable to checkout branches and proper procedure for creating a new branch based off of another one","fromName":"Thomas Anderson","fromEmail":"zelnaga@gmail.com","sentAt":"2010-06-17T02:41:23Z","receivedAt":"2010-06-17T02:41:23Z","isPatch":false,"sender":{"key":"zelnaga@gmail.com","avatar":null},"body":"Say there's a Git repository with two branches: default (which is the\ndefault branch) and branch.  I want to checkout branch and start\nworking on that but am unsure of how to do it.  Here are the commands\nthat I did:\n\ngit clone git@github.com:username/repo.git\ncd repo\ngit checkout branch\n\nBut that gets me the following error:\n\nfatal: Not a git repository (or any of the parent directories): .git\n\nI do \"git branch\" and here's what I see:\n\n* default\n\nWhere's \"branch\"?\n\nAnd let's say I wanted to create my own branch based on \"branch\".\nLet's say \"branch-zelnaga\".  How would I do that?  Do I just checkout\nthat branch, create a new branch while the current working directory\ncontains files from the desired branch and then push / commit as\nappropriate?\n"},{"id":"143845","messageId":"AANLkTillFOvwAK_rHhUjhbjRupD1DnQpcMFB3QbExctt@mail.gmail.com","threadId":"24135","inReplyTo":"AANLkTilZ6zoByCngAGoCbgQ9yd424VcChpTKh_XLnogd@mail.gmail.com","subject":"Re: unable to checkout branches and proper procedure for creating a new branch based off of another one","fromName":"Thomas Anderson","fromEmail":"zelnaga@gmail.com","sentAt":"2010-06-17T03:32:14Z","receivedAt":"2010-06-17T03:32:14Z","isPatch":false,"sender":{"key":"zelnaga@gmail.com","avatar":null},"body":"I guess what I was trying to do was checkout a remote branch.  Of\ncourse, it's unclear to me what the difference between \"git checkout\norigin/branch\" and \"git checkout -b origin/branch\" is.  The latter\ncreates a local branch and the former doesn't?  Does that mean that,\nwith the former, changes I commit and subsequently push will get\nwritten to the remote default branch and not the remote \"branch\"\nbranch?\n\nAnd how do I check that files in the current working directory are\nfrom the desired branch?  \"git log\" shows commits made to the default\nbranch - not to the \"default\" branch, which doesn't give me much\nconfidence...\n\nOn Wed, Jun 16, 2010 at 9:41 PM, Thomas Anderson <zelnaga@gmail.com> wrote:\n> Say there's a Git repository with two branches: default (which is the\n> default branch) and branch.  I want to checkout branch and start\n> working on that but am unsure of how to do it.  Here are the commands\n> that I did:\n>\n> git clone git@github.com:username/repo.git\n> cd repo\n> git checkout branch\n>\n> But that gets me the following error:\n>\n> fatal: Not a git repository (or any of the parent directories): .git\n>\n> I do \"git branch\" and here's what I see:\n>\n> * default\n>\n> Where's \"branch\"?\n>\n> And let's say I wanted to create my own branch based on \"branch\".\n> Let's say \"branch-zelnaga\".  How would I do that?  Do I just checkout\n> that branch, create a new branch while the current working directory\n> contains files from the desired branch and then push / commit as\n> appropriate?\n>\n"},{"id":"143846","messageId":"AANLkTilasCQ1_F0z8NTaJzFNvgnFGImlGN5DcOh0O7VV@mail.gmail.com","threadId":"24135","inReplyTo":"AANLkTillFOvwAK_rHhUjhbjRupD1DnQpcMFB3QbExctt@mail.gmail.com","subject":"Re: unable to checkout branches and proper procedure for creating a new branch based off of another one","fromName":"Thomas Anderson","fromEmail":"zelnaga@gmail.com","sentAt":"2010-06-17T03:44:55Z","receivedAt":"2010-06-17T03:44:55Z","isPatch":false,"sender":{"key":"zelnaga@gmail.com","avatar":null},"body":"Also, directories that are present in the \"branch\" branch aren't\npresent in the current working directory, despite my having switched\nover.  \"git checkout origin/branch\" adds the missing directories but\n\"git checkout -b origin/branch\" does not.  Which leaves me wondering\nwhat the latter is doing.\n\nOn Wed, Jun 16, 2010 at 10:32 PM, Thomas Anderson <zelnaga@gmail.com> wrote:\n> I guess what I was trying to do was checkout a remote branch.  Of\n> course, it's unclear to me what the difference between \"git checkout\n> origin/branch\" and \"git checkout -b origin/branch\" is.  The latter\n> creates a local branch and the former doesn't?  Does that mean that,\n> with the former, changes I commit and subsequently push will get\n> written to the remote default branch and not the remote \"branch\"\n> branch?\n>\n> And how do I check that files in the current working directory are\n> from the desired branch?  \"git log\" shows commits made to the default\n> branch - not to the \"default\" branch, which doesn't give me much\n> confidence...\n>\n> On Wed, Jun 16, 2010 at 9:41 PM, Thomas Anderson <zelnaga@gmail.com> wrote:\n>> Say there's a Git repository with two branches: default (which is the\n>> default branch) and branch.  I want to checkout branch and start\n>> working on that but am unsure of how to do it.  Here are the commands\n>> that I did:\n>>\n>> git clone git@github.com:username/repo.git\n>> cd repo\n>> git checkout branch\n>>\n>> But that gets me the following error:\n>>\n>> fatal: Not a git repository (or any of the parent directories): .git\n>>\n>> I do \"git branch\" and here's what I see:\n>>\n>> * default\n>>\n>> Where's \"branch\"?\n>>\n>> And let's say I wanted to create my own branch based on \"branch\".\n>> Let's say \"branch-zelnaga\".  How would I do that?  Do I just checkout\n>> that branch, create a new branch while the current working directory\n>> contains files from the desired branch and then push / commit as\n>> appropriate?\n>>\n>\n"},{"id":"143849","messageId":"4C19ACDA.3010600@gmail.com","threadId":"24135","inReplyTo":"AANLkTilasCQ1_F0z8NTaJzFNvgnFGImlGN5DcOh0O7VV@mail.gmail.com","subject":"Re: unable to checkout branches and proper procedure for creating a new branch based off of another one","fromName":"Gabriel Filion","fromEmail":"lelutin@gmail.com","sentAt":"2010-06-17T05:04:26Z","receivedAt":"2010-06-17T05:04:26Z","isPatch":false,"sender":{"key":"lelutin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/108728?v=4"},"body":"Hello,\n\nOn 2010-06-16 23:44, Thomas Anderson wrote:\n> Also, directories that are present in the \"branch\" branch aren't\n> present in the current working directory, despite my having switched\n> over.  \"git checkout origin/branch\" adds the missing directories but\n> \"git checkout -b origin/branch\" does not.  Which leaves me wondering\n> what the latter is doing.\n> \n\nHere's for a really short difference between both commands:\n\ngit checkout origin/branch\n^-> tells git to change the working tree to look like the commit that is\npointed to by the remote branch named \"branch\" on the remote named \"origin\".\n\"origin\" is automatically created by \"git clone\" and represents the\nrepository from which you cloned the code.\n\ngit checkout -b origin/branch\n^-> this tells git to create a branch named \"origin/master\" from the\npoint in the history on which you currently are and then to switch to it\n(checkout). In fact, your working tree will not be different as the\nbranch was started where you were, e.g. on the \"default\" branch. The\ndifference will be that commits made from now on will be placed on the\nbranch named \"origin/branch\".\n\n\nThe \"branch\" branch is there, but it is only referenced by the remote\n\"origin\". I believe what you want to do is to execute the following command:\n\ngit branch branch origin/branch\n^-> This one creates a local branch named \"branch\" that tracks the\n\"origin/branch\" remote branch. It will not switch to it, though. You\nneed to do \"git checkout branch\" afterwards to have your worktree\nadjusted. By doing the above command you effectively tell git that you'd\nlike to work on the top of the point \"origin/branch\". Your commits will\nbe local until they are pushed to origin, hence the need to have a local\nbranch that can possibly point to a different place in history.\n\n\nHope that was not too confusing :\\ don't hesitate to ask for precisions ;)\n\n> On Wed, Jun 16, 2010 at 10:32 PM, Thomas Anderson <zelnaga@gmail.com> wrote:\n>> I guess what I was trying to do was checkout a remote branch.  Of\n>> course, it's unclear to me what the difference between \"git checkout\n>> origin/branch\" and \"git checkout -b origin/branch\" is.  The latter\n>> creates a local branch and the former doesn't?  Does that mean that,\n>> with the former, changes I commit and subsequently push will get\n>> written to the remote default branch and not the remote \"branch\"\n>> branch?\n>>\n>> And how do I check that files in the current working directory are\n>> from the desired branch?  \"git log\" shows commits made to the default\n>> branch - not to the \"default\" branch, which doesn't give me much\n>> confidence...\n>>\n>> On Wed, Jun 16, 2010 at 9:41 PM, Thomas Anderson <zelnaga@gmail.com> wrote:\n>>> Say there's a Git repository with two branches: default (which is the\n>>> default branch) and branch.  I want to checkout branch and start\n>>> working on that but am unsure of how to do it.  Here are the commands\n>>> that I did:\n>>>\n>>> git clone git@github.com:username/repo.git\n>>> cd repo\n>>> git checkout branch\n>>>\n>>> But that gets me the following error:\n>>>\n>>> fatal: Not a git repository (or any of the parent directories): .git\n>>>\n>>> I do \"git branch\" and here's what I see:\n>>>\n>>> * default\n>>>\n>>> Where's \"branch\"?\n>>>\n>>> And let's say I wanted to create my own branch based on \"branch\".\n>>> Let's say \"branch-zelnaga\".  How would I do that?  Do I just checkout\n>>> that branch, create a new branch while the current working directory\n>>> contains files from the desired branch and then push / commit as\n>>> appropriate?\n>>>\n>>\n\n\n-- \nGabriel Filion\n"}]}