0

I have some environment specific files in a Git repo.

When I merge my dev branch to master, I don't want to overwrite those files in master with the ones from dev.

How can I set those files to be ignored when merging the branches?

Arghya
  • 240
  • 1
  • 16

2 Answers2

3

Merge and then just check them out:

git merge some_branch --no-commit -m "some merge"
git checkout HEAD -- file1 file2 file3
git merge --continue

You might set GIT_EDITOR to /bin/true if the process is going on in a script:

GIT_EDITOR=/bin/true git merge --continue
Arghya
  • 240
  • 1
  • 16
eftshift0
  • 26,375
  • 3
  • 36
  • 60
  • This workaorund seems to be working. Would have liked to have something like .gitignore for merging but this would work for now. Thanks a ton! – Arghya Jul 23 '20 at 21:44
1

If you push any file to .git and merge the branch to master , it will definitely override the master branch files. No. way to prevent this.

Instead of this, create different config files for different environments and configure Jenkins to use those files.

Chakreshwar Sharma
  • 2,571
  • 1
  • 11
  • 35
  • I wish it was that simple for the files to be configured for Jenkins because different repos are running with different configurations. But thanks for suggestion. – Arghya Jul 23 '20 at 13:52