Suppose I do
git rebase -i HEAD~3
and the following opens up in a text editor:
pick ae27841 Commit 1
pick fd8a71e Commit 2
pick badd490 Commit 3
I want to convert these 3 commits into 1 commit so I can push that commit to my repository and then call a pull request. I understand that there are 2 ways to go about this:
I can leave one commit as
pick
and squash the other two. i.epick ae27841 Commit 1 s fd8a71e Commit 2 s badd490 Commit 3
I can delete 2 of those 3 commits . i.e.
pick ae27841 Commit 1
What is the difference between these 2 commands? As I understand it, each commit is a different version of the project. Hence my latest commit will be my latest version right? So my latest commit is all that I need to keep. Since the other 2 commits are 'older' versions of the project, I have no need for them and so I can delete them. So is method 2
the correct way to go about converting my 3 commits into one?
If so, what kind of a case will I need to squash my commits instead?
What is the correct way here? Squashing or deleting commits?