Wednesday, October 14, 2009

Select commits from another branch using git cherry-pick

Scenario:
Assuming the following commits in my 123-feature-blah_blah branch

commit eff75535f3eaa42dbc41cdaa3e8e404298fcce58
Author: NgTzeYang
Date: Tue Oct 13 12:58:09 2009 +0800

[#1467448] Fix unit test failure for course management

commit 19651c61957f2b5cab9614948fe68c4fd505da04
Author: Jason Ong
Date: Thu Oct 15 14:36:08 2009 +0800

Upgraded cucumber gem to version 0.4.2

commit 534585c488628e0c434399d700ae0e8637afb868
Author: NgTzeYang
Date: Tue Oct 13 12:11:20 2009 +0800

[#1467375] Use different database for unit & integration testing

Problem:
I wanna push 2nd commit to origin/master so others can benefit from this commit while I work on the blah blah feature

Solution:
- create another branch from local master
- find SHA id of commit to cherry pick
- use git cherry-pick to select 2nd commit into the branch
- rebase into local master
- push to origin/master

git checkout master && git checkout -b upgrade_cucumber_gem
git log 123-feature-blah_blah
git cherry-pick 19651c61957f2b5cab9614948fe68c4fd505da04
git checkout master && git rebase upgrade_cucumber_gem
git push origin master

No comments:

Blog Archive