Mzzzzzz
Mzzzzzz

Reputation: 4960

Equivalent of git add --patch with two local files

I have two versions of a long configuration file that have diverged (edited by different users). I want to reconcile them into one file that includes the best of both existing versions.

I know there are dedicated tools for tasks like these (e.g., vimdiff), but I'm used to the workflow of git add --patch for interactive selection of what to include in a reconciled file.

Is there a way to use the git add --patch tooling to combine two files that aren't in git?

Upvotes: 1

Views: 47

Answers (1)

Jeff Puckett
Jeff Puckett

Reputation: 40841

Since you're not eager to use a diff tool like meld, then you can use your familiar flow by copying the files into a new repository.

mkdir temp
cd temp
git init
cp /path/to/config1 ./config
git add .
git commit -m "first config"
cp /path/to/config2 ./config
git add -p
git commit -m "merged second config"
cp config /path/to/config/

Upvotes: 1

Related Questions