Squash commits into one with Git, Rebase | Drupal 8

Squash commits into one with Git, Rebase

Submitted by editor on Tue, 04/06/2021 - 11:02


1. Update branche
git reset --hard origin/features/BRANCHNAME
git pull origin features/BRANCHNAME

2. Rebase
git rebase -i HEAD~N --rebase-merges
git rebase -i HEAD~2 --rebase-merges
git rebase -i COMMIT-NUMBER --rebase-merges

3. Change pick by s (Squash) except first

4. Comment unwanted comment texts

5. Check rebase and push using --force


Rebase a branch: (Avoid if possible)

Example :
git rebase origin/BRANCH-NAME  --rebase-merges


Other commands:

git rebase --continue

git rebase --abort


Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.