Tom and Alice would both to collaborate on a branch of project
, which is hosted on Github. Here is what happened so far:
project
.new-feature
in his fork.new-feature
.project
.git remote add toms-fork git@githum.com:Tom/project.git
.git fetch toms-fork
.Alice: git checkout toms-fork/new-feature
Note: checking out 'toms-fork/new-feature'.
You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example:
git checkout -b
So, this has confused Alice (me). Do I need to make my own branch and submit a PR to Tom to merge into my branch into toms-fork/new-feature
, which will then be merged into project
?
Also, why is Alice (me) in a detached HEAD
state? Why am I not on toms-fork/new-feature
?
You checked out the remote tracking branch called toms-fork/new-feature
. This left you in a detached HEAD state, which isn't want you want. Instead, you probably intended to do this:
git checkout toms-fork/new-feature
git checkout -b alice-branch # create a new branch from new-feature
Then, do all your work on this branch, and when it comes to merge your work back into new-feature
, you can issue a pull request on your alice-branch
. This assumes that you want to share new-feature
with your collaborator Tom. If you want your own branch, you could also have created one in the project
fork directly from the master
branch, e.g.
git checkout master
git checkout -b alice-branch
Then, both Tom's and your branches would eventually be merged back into project
.