-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?

0

1 Answer 1

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).

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.