3

I was wondering, if it's possible to make branches unable to merge? For Example: I have master, branchA, branchB. I'm currently working on branch branchB which is completetely different from the other branches. How to make this branch unable to merge with others?

My bad, if it's a duplicate question.

Malakai
  • 3,011
  • 9
  • 35
  • 49

1 Answers1

1

If the branches are completely different then what you need is a completely separate repository, or a fork if you're using GitHub and the branch in question is at least similar to the other.

A rather ugly workaround would be a hook. There's no pre-merge hook but there is a prepare-commit-msg hook (link to SO answer about pre-merge hooks) which receives an argument that would give you what you'd need to write a script that checks the name of the branch. It'd be ugly. I'm not 100% sure it would work. Realistically, you should go with the first option. If the two branches can never be merged they should be in separate repositories.

Community
  • 1
  • 1
bcmcfc
  • 25,966
  • 29
  • 109
  • 181
  • Sounds like a rocket science to me for now, but could you provide some 'prepare-commit-msg hook' using CLI? Or how it's done via IntelliJ ( if... that possible) Thanks – Malakai Nov 13 '16 at 12:10
  • Your git project will include a sample script at this path: .git/hooks/prepare-commit-msg.sample – bcmcfc Nov 13 '16 at 12:12