mirror of
https://github.com/Bhupesh-V/ugit.git
synced 2026-09-10 07:26:20 -04:00
Fix: Undo initial commit
This commit is contained in:
parent
be9988d4fb
commit
04a8539133
7
ugit
7
ugit
|
|
@ -53,9 +53,14 @@ undo_git_commit() {
|
|||
[ -z "$commit" ] && exit
|
||||
|
||||
last_commit=$(git log --format="%h" -n 1)
|
||||
initial_commit=$(git rev-list --max-parents=0 --abbrev-commit HEAD)
|
||||
|
||||
if [[ "$last_commit" == "$commit" ]]; then
|
||||
if git reset HEAD~; then
|
||||
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."
|
||||
fi
|
||||
elif git reset HEAD~; then
|
||||
printf "%s\n" "Commit: $last_commit successfully undone"
|
||||
fi
|
||||
elif git revert "$commit"; then
|
||||
|
|
|
|||
Loading…
Reference in a new issue