-1

I have committed a piece of code as commit1 but after finishing it, I want to remove the commit1 and commit the entire code as Initial Commit.

When I run git reset HEAD~ in Git Bash, it results in deleting all my code.

Is it possible to delete commit1 instead of everything, and how?

ruohola
  • 21,987
  • 6
  • 62
  • 97
Spandan
  • 17
  • 3

1 Answers1

1

Yes. You can for example run:

git rebase --interactive --root

And then change the action before the commit you want to squash to f (it stands for fixup = squash the commit to the previous one and discard the commit message). Then simply save and close the file (using :wq if it opened the default Vim editor).

ruohola
  • 21,987
  • 6
  • 62
  • 97