Miguel Stevens
Miguel Stevens

Reputation: 9191

Copy specific Git commits to master branch

I have a master and a development branch.

I mostly work on the development branch until we can do a sort of release, then merge that branch into master.

Now I added an important commit onto the develop branch, but there's also many other commits there.

Is it possible to "pick" this 1 commit and add it to the master branch, without merging the other commits on my develop branch?

The commit I need is the last commit on the develop branch.

Upvotes: 0

Views: 74

Answers (2)

steadweb
steadweb

Reputation: 16551

To "copy" a commit from one branch to another, use the cherry-pick command. Make sure you're on on the master branch before cherry-picking.

To checkout the master branch:

git checkout master

Then cherry-pick the commit onto master. You'll need to know the commit <sha>.

git cherry-pick <sha>

Upvotes: 2

Chris
Chris

Reputation: 136880

Yes, you can use cherry-pick:

Given one or more existing commits, apply the change each one introduces, recording a new commit for each.

E.g.

git checkout master
git cherry-pick <revision>

Upvotes: 2

Related Questions