2

I know it's been answered before, but i didn't make much sense of the answers. I have a repository with two branches that run in parallel. One is master and the other one is seed. The seed and master branches contain two files that are needed for local and live server environments, so they differ. Seed has configurations for local, master for live.

From time to time, i want to merge the master branch into the seed branch to get it up to speed, but i want to exclude from the merge, the two respective files.

I tried creating a .gitignore file and adding the files there, however this only affects push/pull to the repository. If i modify file A in the master, that's supposed to be ignored, when i merge the master branch into the seed branch, the file is in the seed branch with the modifications i made in the master. This i want to avoid, so that any modifications of file A in the master branch does not carry over to the seed branch upon merge (and viceversa!).

Radu Andrei
  • 1,075
  • 10
  • 19
  • Ignoring files during a merge is the same as *always keeping the local version* - a full description of how to do this is given [here](http://stackoverflow.com/questions/928646/how-do-i-tell-git-to-always-select-my-local-version-for-conflicted-merges-on-a-s) – adelphus Aug 12 '15 at 17:08
  • @adelphus From what i gather in that answer, that only applies to conflicts (when git detects a conflict). Also it seems a bit convoluted, but i may just need to read it a couple more times to properly understand it. I'm looking to see if Git has a native way of saying "merge these two branches but ignore X file". – Radu Andrei Aug 12 '15 at 17:13

1 Answers1

0

This is a bit of a convoluted workflow, but here's one way you can accomplish it. Every time you want to merge master into seed, do it this way:

# git checkout seed
# git merge --no-commit master
# git reset seed -- file1 file2
# git checkout file1 file2
# git commit
twalberg
  • 59,951
  • 11
  • 89
  • 84