4

We have two repositories: Upstream and Downsteram, with a single config.lua file that can be different between them. We want to use Pull Requests from Downstream to Upstream (and vice-versa), while ignoring the config.lua file.

Relevant SO answers that aren't usable:

We don't want to spend time excluding the config.lua file each time, so the answer in Github - Pull Request, ignore some file changes doesn't work for us.

This answer (Using git, how do I ignore a file in one branch but have it committed in another branch?) doesn't work anymore apparently (and this is the same master branch anyway).

I couldn't get Github to work with the answer given in https://stackoverflow.com/a/8014154/7656871 . I've tried the following:

  1. created the config.lua file and changed it differently so as to cause a conflict (which seems like a hack, but apparently needed!)
  2. added .gitattributes with content config.lua merge=ours
  3. added .gitconfig with content: [merge "ours"] driver = true
  4. the github PR still detects the change and claims it cannot automatically merge.

I also think it's a bad hack to have to create a merge conflict so this merge strategy would fire (see Is it possible to exclude specific commits when doing a git merge?). It will make the process complicated if there are multiple Downstream forks.

Is there no simple way to ignore one Downstream configuration file when doing pull requests?

Community
  • 1
  • 1
Gajo Petrovic
  • 351
  • 3
  • 4

1 Answers1

0

First of all, GitHub is just a pretty frontend for Git repos. So this is a Git question since a GitHub PR is really about merging two branches - there's no way of excluding files there.


The solution for this problems is usually to not commit config files at all but rather commit a foo.cfg.example while adding foo.cfg on gitignore.

If you cannot avoid commiting config files, why not give them unique names - e.g. foo-team1.cfg, foo-team2.cfg, etc? That way they are tracked but you won't have conflicts or problems with other people's config changes overwriting yours.

ThiefMaster
  • 310,957
  • 84
  • 592
  • 636