user8024280
user8024280

Reputation:

How to maintain 2 branches in git which differ only in 1 commit

I have in git 2 branches, which contain following commits:

commits in branch a:

A -> B -> C -> D -> ... -> N

commits in branch b:

A -> B -> X -> C -> D -> ... -> N

The difference between branch a and b is that branch b contains one more commit, commit X. I want both branches stay the same except that commit X. So when now I commit something to branch a, I always have to cherry-pick it into branch b. Is there any smarter solution how to solve this issue in git? Because cherry-picking all the future commits I do not consider as a good idea.

Upvotes: 0

Views: 66

Answers (1)

customcommander
customcommander

Reputation: 18901

What I'd do is to move commit X to the head of branch b. In this case when branch a gets new commits in, you can simply do:

git checkout b
git rebase a

One obvious caveat though: you cannot rewrite the history in branch a. This assumes that you keep adding commits on top of a.

Upvotes: 1

Related Questions