user2024080
user2024080

Reputation: 5091

How to copy a specific commit to another Branch?

In my git master I have 2 branches as production and testing. I do all work with testing. at present example my production version is 5. my testing version is 20. now I would like to update the production version from testing version of 15.

for that, how can i select the testing version of 15 and copy or merge to production version of 5? ( if the new testing version commit as id of 6 in the production version that' fine )

if anything wrong here please excuse me.

I don't have any idea. please help me.

Upvotes: 0

Views: 1944

Answers (4)

ckruczek
ckruczek

Reputation: 2410

I would suggest you checkout (git checkout) the testing branch at the specific commit for version 15. then create a temporary branch git checkout -b version15merge and merge git checkout production && git merge version15merge this stuff into your production branch.

Upvotes: 1

Aditya Singh
Aditya Singh

Reputation: 16650

Use git cherry-pick <commit-hash from the source branch > when your destination branch is checked out. In your case find the commit-hash of version 15 in testing branch and then checkout the master branch and run the below:

git cherry-pick <commit-hash of version 15 from testing branch> 

Upvotes: 0

Vampire
Vampire

Reputation: 38629

If you want to copy single commits, use git cherry-pick.
If you want to merge all changes in testing up to 15, just use git merge 15 to merge over the changes to production.

Upvotes: 0

koninos
koninos

Reputation: 5327

Use git cherry-pick and the SHA1 of the commit you want to copy.

Upvotes: 1

Related Questions