Git: Bettter way than cherry-pick to merge two branches?
Newbie on git, i have two branches in my git project, master and feature, both branches share 80% of the same code, while the other 20% are different, Now i'm working on master, i make a commit on master, and this commit also should be applied to feature branch, if i use merge, there will be conflict as the other 20% code are different, i have to use cherry-pick, and the commit history of the two branches are parallel. This is annoying as i have to cherry-pick every commit from master to feature branch.
Is there one better way to achieve this?
You have a massive problem here, because your branches already differ way too much.
To prevent this, you need to keep them in sync as much as possible.
For future scenarios like this, there are two possible approaches, both of which need to be applied from the beginning:
- Merge frequently from master to feature
- Frequently rebase feature onto master
I'm pretty sure you can check out specific files with:
git checkout <branch> <commit-ref> <filepath>
If the updates you want to push between branches are contained to specific files then that should let you sync up manually at least.