Skip to content

Instantly share code, notes, and snippets.

@xntrik
Last active December 20, 2015 17:39
Show Gist options
  • Save xntrik/6170608 to your computer and use it in GitHub Desktop.
Save xntrik/6170608 to your computer and use it in GitHub Desktop.
Git merge selectively from different branch
$ git branch
* master
twitter_integration
$ git checkout twitter_integration app/models/avatar.rb db/migrate/20090223104419_create_avatars.rb test/unit/models/avatar_test.rb test/functional/models/avatar_test.rb
$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: app/models/avatar.rb
# new file: db/migrate/20090223104419_create_avatars.rb
# new file: test/functional/models/avatar_test.rb
# new file: test/unit/models/avatar_test.rb
#
$ git commit -m "'Merge' avatar code from 'twitter_integration' branch"
from http://jasonrudolph.com/blog/2009/02/25/git-tip-how-to-merge-specific-files-from-another-branch/
To compare a file between two branches:
git diff mybranch master -- myfile.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment