timpone
timpone

Reputation: 19969

How to create new branch and merges differences from another branch into it with exception of a single directory

I have a branch that I did a bunch of Rubocop changes to (called dev/rubocop-changes). I'd like to create a branch (called dev/rubocop-changes-no-app) that takes all the changes from this with the exception of changes in the /app directory (ie /spec, / etc....).

How would I do this?

Upvotes: 1

Views: 42

Answers (1)

Romain Valeri
Romain Valeri

Reputation: 22017

This would be a way to do it :

1) Creating the new branch from your main trunk (let's assume dev here for the example)

git checkout dev
git checkout -b dev/rubocop-changes-no-app

2) Taking all your changes from the Rubocop branch (but preventing the merge from finishing)

git merge --no-commit dev/rubocop-changes

3) Rewinding the /app directory back to the state it was before the merge

git checkout dev -- /app/*

4) Then finishing the merge commit

git commit -am "merge commit message here"

Upvotes: 3

Related Questions