* unable to checkout branches and proper procedure for creating a new branch based off of another one @ 2010-06-17 2:41 Thomas Anderson 2010-06-17 3:32 ` Thomas Anderson 0 siblings, 1 reply; 4+ messages in thread From: Thomas Anderson @ 2010-06-17 2:41 UTC (permalink / raw) To: git Say there's a Git repository with two branches: default (which is the default branch) and branch. I want to checkout branch and start working on that but am unsure of how to do it. Here are the commands that I did: git clone git@github.com:username/repo.git cd repo git checkout branch But that gets me the following error: fatal: Not a git repository (or any of the parent directories): .git I do "git branch" and here's what I see: * default Where's "branch"? And let's say I wanted to create my own branch based on "branch". Let's say "branch-zelnaga". How would I do that? Do I just checkout that branch, create a new branch while the current working directory contains files from the desired branch and then push / commit as appropriate? ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: unable to checkout branches and proper procedure for creating a new branch based off of another one 2010-06-17 2:41 unable to checkout branches and proper procedure for creating a new branch based off of another one Thomas Anderson @ 2010-06-17 3:32 ` Thomas Anderson 2010-06-17 3:44 ` Thomas Anderson 0 siblings, 1 reply; 4+ messages in thread From: Thomas Anderson @ 2010-06-17 3:32 UTC (permalink / raw) To: git I guess what I was trying to do was checkout a remote branch. Of course, it's unclear to me what the difference between "git checkout origin/branch" and "git checkout -b origin/branch" is. The latter creates a local branch and the former doesn't? Does that mean that, with the former, changes I commit and subsequently push will get written to the remote default branch and not the remote "branch" branch? And how do I check that files in the current working directory are from the desired branch? "git log" shows commits made to the default branch - not to the "default" branch, which doesn't give me much confidence... On Wed, Jun 16, 2010 at 9:41 PM, Thomas Anderson <zelnaga@gmail.com> wrote: > Say there's a Git repository with two branches: default (which is the > default branch) and branch. I want to checkout branch and start > working on that but am unsure of how to do it. Here are the commands > that I did: > > git clone git@github.com:username/repo.git > cd repo > git checkout branch > > But that gets me the following error: > > fatal: Not a git repository (or any of the parent directories): .git > > I do "git branch" and here's what I see: > > * default > > Where's "branch"? > > And let's say I wanted to create my own branch based on "branch". > Let's say "branch-zelnaga". How would I do that? Do I just checkout > that branch, create a new branch while the current working directory > contains files from the desired branch and then push / commit as > appropriate? > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: unable to checkout branches and proper procedure for creating a new branch based off of another one 2010-06-17 3:32 ` Thomas Anderson @ 2010-06-17 3:44 ` Thomas Anderson 2010-06-17 5:04 ` Gabriel Filion 0 siblings, 1 reply; 4+ messages in thread From: Thomas Anderson @ 2010-06-17 3:44 UTC (permalink / raw) To: git Also, directories that are present in the "branch" branch aren't present in the current working directory, despite my having switched over. "git checkout origin/branch" adds the missing directories but "git checkout -b origin/branch" does not. Which leaves me wondering what the latter is doing. On Wed, Jun 16, 2010 at 10:32 PM, Thomas Anderson <zelnaga@gmail.com> wrote: > I guess what I was trying to do was checkout a remote branch. Of > course, it's unclear to me what the difference between "git checkout > origin/branch" and "git checkout -b origin/branch" is. The latter > creates a local branch and the former doesn't? Does that mean that, > with the former, changes I commit and subsequently push will get > written to the remote default branch and not the remote "branch" > branch? > > And how do I check that files in the current working directory are > from the desired branch? "git log" shows commits made to the default > branch - not to the "default" branch, which doesn't give me much > confidence... > > On Wed, Jun 16, 2010 at 9:41 PM, Thomas Anderson <zelnaga@gmail.com> wrote: >> Say there's a Git repository with two branches: default (which is the >> default branch) and branch. I want to checkout branch and start >> working on that but am unsure of how to do it. Here are the commands >> that I did: >> >> git clone git@github.com:username/repo.git >> cd repo >> git checkout branch >> >> But that gets me the following error: >> >> fatal: Not a git repository (or any of the parent directories): .git >> >> I do "git branch" and here's what I see: >> >> * default >> >> Where's "branch"? >> >> And let's say I wanted to create my own branch based on "branch". >> Let's say "branch-zelnaga". How would I do that? Do I just checkout >> that branch, create a new branch while the current working directory >> contains files from the desired branch and then push / commit as >> appropriate? >> > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: unable to checkout branches and proper procedure for creating a new branch based off of another one 2010-06-17 3:44 ` Thomas Anderson @ 2010-06-17 5:04 ` Gabriel Filion 0 siblings, 0 replies; 4+ messages in thread From: Gabriel Filion @ 2010-06-17 5:04 UTC (permalink / raw) To: Thomas Anderson; +Cc: git Hello, On 2010-06-16 23:44, Thomas Anderson wrote: > Also, directories that are present in the "branch" branch aren't > present in the current working directory, despite my having switched > over. "git checkout origin/branch" adds the missing directories but > "git checkout -b origin/branch" does not. Which leaves me wondering > what the latter is doing. > Here's for a really short difference between both commands: git checkout origin/branch ^-> tells git to change the working tree to look like the commit that is pointed to by the remote branch named "branch" on the remote named "origin". "origin" is automatically created by "git clone" and represents the repository from which you cloned the code. git checkout -b origin/branch ^-> this tells git to create a branch named "origin/master" from the point in the history on which you currently are and then to switch to it (checkout). In fact, your working tree will not be different as the branch was started where you were, e.g. on the "default" branch. The difference will be that commits made from now on will be placed on the branch named "origin/branch". The "branch" branch is there, but it is only referenced by the remote "origin". I believe what you want to do is to execute the following command: git branch branch origin/branch ^-> This one creates a local branch named "branch" that tracks the "origin/branch" remote branch. It will not switch to it, though. You need to do "git checkout branch" afterwards to have your worktree adjusted. By doing the above command you effectively tell git that you'd like to work on the top of the point "origin/branch". Your commits will be local until they are pushed to origin, hence the need to have a local branch that can possibly point to a different place in history. Hope that was not too confusing :\ don't hesitate to ask for precisions ;) > On Wed, Jun 16, 2010 at 10:32 PM, Thomas Anderson <zelnaga@gmail.com> wrote: >> I guess what I was trying to do was checkout a remote branch. Of >> course, it's unclear to me what the difference between "git checkout >> origin/branch" and "git checkout -b origin/branch" is. The latter >> creates a local branch and the former doesn't? Does that mean that, >> with the former, changes I commit and subsequently push will get >> written to the remote default branch and not the remote "branch" >> branch? >> >> And how do I check that files in the current working directory are >> from the desired branch? "git log" shows commits made to the default >> branch - not to the "default" branch, which doesn't give me much >> confidence... >> >> On Wed, Jun 16, 2010 at 9:41 PM, Thomas Anderson <zelnaga@gmail.com> wrote: >>> Say there's a Git repository with two branches: default (which is the >>> default branch) and branch. I want to checkout branch and start >>> working on that but am unsure of how to do it. Here are the commands >>> that I did: >>> >>> git clone git@github.com:username/repo.git >>> cd repo >>> git checkout branch >>> >>> But that gets me the following error: >>> >>> fatal: Not a git repository (or any of the parent directories): .git >>> >>> I do "git branch" and here's what I see: >>> >>> * default >>> >>> Where's "branch"? >>> >>> And let's say I wanted to create my own branch based on "branch". >>> Let's say "branch-zelnaga". How would I do that? Do I just checkout >>> that branch, create a new branch while the current working directory >>> contains files from the desired branch and then push / commit as >>> appropriate? >>> >> -- Gabriel Filion ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-06-17 5:04 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-06-17 2:41 unable to checkout branches and proper procedure for creating a new branch based off of another one Thomas Anderson 2010-06-17 3:32 ` Thomas Anderson 2010-06-17 3:44 ` Thomas Anderson 2010-06-17 5:04 ` Gabriel Filion
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).