3

I did a commit in Android Studio but I want to make more changes but I also don't want to do another commit.

I can see my commit here enter image description here

What I want to do, is to get back my changes here and delete this commit without pushing it to Github.

enter image description here

Can someone help me with this issue?

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
HeraGonz
  • 315
  • 1
  • 9
  • Does this answer your question? [How to un-commit last un-pushed git commit without losing the changes](https://stackoverflow.com/questions/19859486/how-to-un-commit-last-un-pushed-git-commit-without-losing-the-changes) – Gino Mempin May 13 '23 at 03:20

2 Answers2

1

Use this command

git reset --soft HEAD^
-1

get the desired commit hash by using on the BRANCH_NAME which contains the commit you want :

git log 

copy the hash and use this command

git checkout COMMIT_HASH

then will generate a temp branch, to save it you can use

git switch -c NEW_BRANCH_NAME

to rollback your old branch to this commit run the following two commands

git checkout BRANCH_NAME
git merge NEW_BRANCH_NAME