When merging a branch A with another branch B, how to exclude some commits from B to merge?
For example, B has 100 commits, how can I merge the specific 98 commit and exclude the 2?
When merging a branch A with another branch B, how to exclude some commits from B to merge?
For example, B has 100 commits, how can I merge the specific 98 commit and exclude the 2?
So for example if you're on branchB and you git add . and git commit you could git reset <file name> for the ones you want to exclude then when you merge branchB into branchA it will only include the 98 that are committed.
git cherry-pickThat might be the command you want. It ables you to select the commits you want.
https://git-scm.com/docs/git-cherry-pick
git cherry-pick [--edit] [-n] [-m parent-number] [-s] [-x] [--ff]
[-S[]] …
git cherry-pick --continue
git cherry-pick --quit
git cherry-pick --abort
Given one or more existing commits, apply the change each one introduces, recording a new commit for each. This requires your working tree to be clean (no modifications from the HEAD commit).
After the merge you could rebase interactively and exclude the unwanted commits:
git rebase -i HEAD~100
You may want to create an intermediate branch from the source do rebase -i and then merge that into your target branch.
Something like the following.
git checkout source
git checkout -b middle
git rebase -i HEAD~100 or commit-ish
git checkout target
git merge middle