How to zammitti changes in 2 different branches?

Hello, the whole subject.

There are 2 branches: master and client, where the title is stored in the first working version of the project, and the branch client is the same project but with custom changes (other color palette, renamed units, modified page, etc). In General, client is master plus all add-ons added to the project.

At some stage there comes the need to change the behavior of the project as a whole (in both branches master and client), it does not change Merja client a to the master branch.

In the end the question is, what do I need to do to for example edit the file rest-api.php in both branches, while leaving all other files in these branches intact (something index.php and other files to the master branch remained the same as it was before, and for branch client index.php and other files would be with add-ins client, while rest-api.php would have changed in both branches)

It is clear HEAD for both branches, add all the new changes in stash and after successively switching each of the branches and zammitti changes?

If you could write a command sequence.

P. s or should I create a new branch from master to make changes to the required file and smiriti a new branch from master and client?

Thank you.
June 10th 19 at 14:32
2 answers
June 10th 19 at 14:34
to commit the changes to the file rest-api.php to copy the hash of the commit to switch to the target branch (client) and execute

git cherry-pick %HASKANITA%
June 10th 19 at 14:36
Cherepki is certainly convenient, but can lead to unpleasant consequences. This is the first duplication of commits, and second, if you forget something seripisut, your client will stop working and you will long to understand what was happening.

Solution two:
1. If your branch client - just improvements to the master branch, you can rebase and move the client on top of master. It changes history, so is not for everyone, but if you work with the repository alone, it is a normal solution (the story will be beautiful).
2. So you don't need to merit client to master, and once again contrary smarita master to client and will be exactly what you need.

Find more questions by tags GitVersion control systems