Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interactively merge files tracked with git and untracked local files

I use a couple of software packages (like gitlab) that you install by cloning from their git repo. They typically come with some config.example (under version control), which you copy to your own config file (not under version control or even ignored in .gitignore) and adapt to your needs.

When the upstream package is updated and for example changes the config file options that will obviously only be reflected in config.example.

Is there a chain of git commands that i'm missing that can help me compare the changes of config.example to the new one in upstream/HEAD and maybe even merge them interactively into my local config file?

Would be awesome if i could get something like the interactive patch mode in git add/commit --interactive.

like image 729
Jörn Hees Avatar asked May 23 '15 13:05

Jörn Hees


1 Answers

git checkout --patch selects diff hunks, simplest here might be to put your content at the upstream path, do that, and clean up after:

cp config  config.example
git checkout -p upstream   config.example
mv config.example  config
git checkout @  config.example

that will get you the two-diff hunk selection from git add --patch.

like image 124
jthill Avatar answered Nov 15 '22 23:11

jthill