How to create files with specific branches on GitHub

I would like to have branch-related files with the same name. I need to be able to integrate with my development branch to manage without changes made to this file.

For instance:
Suppose I would like to have two different readme.md . In one I would like to have content: MASTER and in another DEV . But if I try to do this by creating a pull-request, GitHub will try to merge this file, which is exactly my problem. I do not want GitHub to merge this file every time I make changes.

What would be the best way to solve this problem?

+6
source share
1 answer

Say project is the name of the branch to be merged, and README.md is the name of the file that stores industry-specific information.

I would suggest the following steps:

  • Merge the project branch, but make sure that the changes are not executed, not redirected

     $ git merge --no-commit --no-ff project 
  • Disable the README.md file and check its current version of the branch

     $ git checkout HEAD -- README.md 
  • Full merger

     $ git commit 

In addition, it makes sense to install a merge driver that will support a branch-specific version of the file in the event of a merge conflict. In this case, you do not have to manually resolve conflicts in separate files.

Such a merge driver is usually called ours and is defined as:

 $ git config --global merge.ours.driver true 

Now you can specify in the .gitattributes file when this merge should be used.

In our case, we need to add the following rule to .gitattributes and fix it:

README.md merge=ours

+4
source

All Articles