Could someone please tell me what would be an equivalent of git reset --soft HEAD^
for an initial commit? I'm trying to find a really safe one-liner without any deletions :)
To further clarify: I want all the files I tediously added to be in the index and ready for committing after the command is run.
git reset --soft , which will keep your files, and stage all changes back automatically. git reset --hard , which will completely destroy any changes and remove them from the local directory. Only use this if you know what you're doing.
When using git reset --soft HEAD~1 you will remove the last commit from the current branch, but the file changes will stay in your working tree. Also the changes will stay on your index, so following with a git commit will create a commit with the exact same changes as the commit you "removed" before.
As you found, for the initial commit using git reset --soft HEAD^
doesn't work.
What does work is using git update-ref -d HEAD
.
But provided that there is only one branch and one commit, it's can be easier to just delete the .git
directory and start over. Of course, you should only do that if you know what you are doing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With