Reputation: 5849
So I have two branches on git: develop
and release
. I have been using the develop
branch until now. I just made a commit to the develop
branch which I want to be available in the release
branch. How do I do it? I am a little confused here.
1) Does this automatically happen when I do
git checkout -b release
2) To switch back to the develop
branch, I can just do a checkout, right? or do I need to do a merge?
Upvotes: 0
Views: 72
Reputation: 24508
You have a few options for making a commit on one branch available to another -- which you choose depends on how you want your history to look, later.
release
branch that has two parents: the tip of develop
and the former tip of release
. release
will then have all of the work from develop
and release
. To merge develop
into release
, make sure you have a clean working copy, and run git checkout release
, then git merge develop
.develop
on top of release
. Cherry-picking creates a new commit on release
that performs the exact changes that were done in a commit you name. This is useful if you've done a bunch of work on develop
, but you only want one or two things brought over. To cherry-pick, look at git log
, copy the sha hash that names the commit you want, and run git checkout release
, then git cherry-pick <commit hash>
.To answer your follow-on questions:
Nope! The general purpose of git checkout
is to make your working copy look like a thing that you name. When you run git checkout release
, git will change the actual files in your working copy to the state that was last committed to release
. Checkout doesn't change existing branches. (Also, you don't need the -b
if release
already exists; checkout -b
is a convenient shortcut to create and checkout a branch in one shot.)
Along the same lines, to switch back, all you'd need to do is git checkout develop
again.
Upvotes: 2
Reputation: 2093
If you want to bring changes from one branch to another, you have to do a merge.
Upvotes: 0