7

I'd like to have a git repository with a branch for development and a branch for deployment. I have several configuration and database files that my project needs. I want the deployment branch not to have any configuration or database files for my project, but I want to keep versions of those files in my development branch in order to be able to test. Is there any way, when merging the development branch into the deployment branch, to have the merge process ignore those files?

Rex
  • 73
  • 3

3 Answers3

6

You could use git merge --no-commit and delete the config files before committing the merge. There might be more streamlined possibilities, though.

However, I'd recommend either having the files in both branches or not having them at all. What language and development environment are you using? Do they offer some possibility for specifying different files depending on what kind of build you are trying to make?

Aasmund Eldhuset
  • 37,289
  • 4
  • 68
  • 81
  • I've run into this scenario with several different projects, so I didn't have any language/build system in mind. Specifying different files depending on whether I'm testing or deploying certainly works; I just thought it might be more elegant to have git handle this. Maybe that's not what git's designed for, though. – Rex Jun 19 '11 at 23:06
3

From the pro git book: http://git-scm.com/book/en/Customizing-Git-Git-Attributes#Merge-Strategies

On your branch

 echo 'myconfig.cfg merge=ours' >> .gitattributes

You can either gitignore (man gitignore) or keep .gitattributes locally only in your branch.

PhilG
  • 9
  • 3
sehe
  • 374,641
  • 47
  • 450
  • 633
0

You can do a pseudo-merge. This would really be a rebase of commits from what was not merged yet. So if at some point you merged before and preserved the way the two branches looked, you should only be merging what differences the commits introduced after the last merge.

Here is the answer that describes this "special merge":

Always ignore a certain commit on merge in git

Community
  • 1
  • 1
Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141