Fix: undo initial commit- update comments

This commit is contained in:
kopalchakravarty 2022-08-15 16:04:53 +05:30
parent ae010592da
commit dd6b72346d

2
ugit
View file

@ -56,6 +56,8 @@ undo_git_commit() {
initial_commit=$(git rev-list --max-parents=0 --abbrev-commit HEAD)
if [[ "$last_commit" == "$commit" ]]; then
# If the last commit is the same as the initial commit, delete reference to the branch(update-ref) and unstage changes of the initial commit(git rm).
# This will not delete the files from your working directory
if [[ "$last_commit" == "$initial_commit" ]]; then
if git update-ref -d HEAD && git rm --cached -rf . > /dev/null 2>&1; then
printf "%s\nInitial commit: $initial_commit successfully undone. Commit state is clean."