Applying patches with modifications from other branch

Normally we create a new branch on git to test a new code and when it is working fine we want to move it again to master. There are many ways to do it.

Today my friend Daniel found a nice way to do it:

git diff master mytestbranch | git apply --index -

It will move all modified files from “mytestbranch” to “master” branch.

If you want to move just a specific directory or file, you can follow the command by “– “, example:

git diff master mytestbranch -- src/ | git apply --index -

In this case I just want the modifications which affect the src/ directory.

Advertisements

One thought on “Applying patches with modifications from other branch

  1. This is useful in case you don’t want to transfer all the history between branches, just the finished work. ūüėÄ

    If you have binary files use –binary for git-diff.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s