0

I have a repository on GitHub where I have two branches, main and production. production is my development environment and main my release environment. But I have a CHANGELOG.md file in production that I don't want in main because I want there a changelog file unique for main.

Is there a way that I can merge my procuction branch with my main branch without merging CHANGELOG.md?

DJS
  • 35
  • 1
  • 6
  • Does the file exist on both branches with different content? Are you always merging the same direction? For example, do you sometimes merge `main` into `production` and also sometimes merge `production` into `main` (note this could possibly happen indirectly through a hotfix branch), or is it always just one way? Note what you're asking is *possible* with a little extra effort for *every* merge between the two branches. However, it's likely there is a better way to solve the problem regarding the *reason* you wish to maintain two different versions of the same file. E.g. why not have 2 files? – TTT Mar 03 '22 at 18:09

1 Answers1

0

Git won't allow you to merge one branch into another if there are conflicts in files. When merging, you have to decide on your own what version of file you are going to save in main. If you want to keep main's changelog, you should keep the version stored in main by opening this file after merging and removing the corresponding error markers. The changelog on production branch will not be affected.

UPD As it was mentioned in the comments, it doesn't happen all the time that you have conflicts. The solution may really be to have a different file for each branch.

twentysixhugs
  • 324
  • 3
  • 10
  • This might work when there are conflicts, but it's possible (even likely) that there won't always be conflicts. – TTT Mar 03 '22 at 19:32