Git: merging specific files from another branch


Jason Rudolph has a great blog post on merging files from one branch to another in git. In most cases you probably want to cherry-pick commits, however for a quick and fast solution this is pretty cool:

$ git branch
* master
$ git checkout twitter_integration app/avatar.rb
$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#   new file:   app/models/avatar.rb
$ git commit -m "'Merge' avatar code from 'twitter_integration' branch"
[master]: created 4d3e37b: "'Merge' avatar code from 'twitter_integration' branch"
1 file changed, 72 insertions(+), 0 deletions(-)

Two things i noticed about this method:

Add a comment