⊗gtPmBrCCR 45 of 65 menu

More complex rebasing of commits in Git

In Git, you can rebase three branches. Let's say we have two branches member1 and member2 that have different commits.

While working on the project, we needed to insert commits commit3, commit4 from the branch member2 into the branch member1 and apply them on the branch master. To do this, run the following command:

git rebase --onto master member1 member2

This command tells Git to switch to the member2 branch, find commits in it that are not in the member1 branch, and merge only those missing commits into the master branch.

Now let's perform a reverse merge:

git switch master git merge member2

One thing to remember is that you can't rebase commits that are in an remote repository. Everyone on the team pulls commits from it to complete their task, but if branches are rebased, everyone has to merge commits back into their branches, which can cause more confusion.

English
БеларускаяDeutschEspañolFrançaisPortuguêsРусский
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline