While working on my branch i merged the master branch to keep my work up to date with the master.
Now when I want to clean up my commit history (squash / pick) i get all the commits from the master branch as well by git rebase myBranch -i HEAD myfirstcommit
How can I filter out the commits from the master branch, so I can only rearrange my own commits?
In case of git rebase --onto we can change the point where our branch is starting not only to the last commit on parent branch, but we can choose specific commit where we start and also where we finish. This is true not only on one specific branch but for other branches (all valid commits) too.
You can run rebase interactively by adding the -i option to git rebase . You must indicate how far back you want to rewrite commits by telling the command which commit to rebase onto. Remember again that this is a rebasing command — every commit in the range HEAD~3..
On the command line, navigate to the repository that contains the commit you want to amend. Use the git rebase -i HEAD~n command to display a list of the last n commits in your default text editor. Replace pick with reword before each commit message you want to change.
After you've merged master
into your branch, while staying in your branch, do the following:
git rebase -i master
This will rebase your branch on top of master
, taking only new commits, that are in your branch, but not in master
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With