Reputation: 42459
I have a code which I track with git + Github
. Currently I have a master and a test branch:
$ git branch
* master
test-branch
What I want to do is to clone the state of test-branch
into a new test-branch-2
branch to work with. I know I can do this with:
git checkout -b test-branch-2 test-branch
If I later on decide I'm done with test-branch
and delete it (perhaps after merging it into master
), will this affect my test-branch-2
at all?
Upvotes: 0
Views: 67
Reputation: 137215
Deleting your test-branch
will not affect test-branch-2
.
If your repository looks like
test-branch2 G---H
/
test-branch E---F
/
master A---B---C---D
and you merge test-branch
into master
, then delete test-branch
you'll end up with something like this:
test-branch2 E---F---G---H
/ \
master A---B---C---D---I
Note that test-branch2
still contains commits A
, B
, C
, E
, F
, G
and H
, in the same order as before. The new commit I
is the merge commit from merging test-branch
into master
.
If you are interested in the details, I advise you to check out the excellent website Think like a Git, particularly the section on reachability. (If you are new to graph theory, start at the beginning. All you need to know is introduced gradually.)
Upvotes: 3