-2

How do I squash 2, 3 and 4 into a single commit?

  1. last commit
  2. last commit -1
  3. last commit -2
  4. last commit -3
  5. last commit -4
John Smith
  • 465
  • 1
  • 4
  • 18
  • Interactive rebase? – matt Dec 09 '19 at 18:37
  • Does this answer your question? [Combining multiple commits before pushing in Git](https://stackoverflow.com/questions/6934752/combining-multiple-commits-before-pushing-in-git) – phd Dec 09 '19 at 20:07
  • https://stackoverflow.com/search?q=%5Bgit%5D+combine+commits – phd Dec 09 '19 at 20:07

1 Answers1

0

Interactive rebase as told by matt, or this way, with no interactive stuff:

git checkout commit2
git reset --soft commit5
git commit -m "Here's the squash"
git cherry-pick commit1

Done!

eftshift0
  • 26,375
  • 3
  • 36
  • 60