vego
vego

Reputation: 1059

How to keep two branches in sync but keep some separate code different?

For example, I have two branches: master and client

They all have a some file main.c with one line different:

master:main.c:

char *private = 'main';
int main() {
/*
...
*/
}

client:main.c:

char *private = 'client';
int main() {
/*
...
*/
}

client branch needs to keep in sync with master but keep the line char *private not changed.

How to do this ?

This is a simplified example, in practice, I have a few more different code

Upvotes: 0

Views: 168

Answers (1)

Mahdi Aryayi
Mahdi Aryayi

Reputation: 1120

The best way to do this is by keeping one of these branches (e.g. master) as base branch and regularly rebase the other branch with it.

____master
         |
         |____client

when there is a change in main.c update it in master and then rebase the client with the new master:

$ git checkout client
$ git rebase master

Upvotes: 1

Related Questions