Skip to content

Instantly share code, notes, and snippets.

@MrZenW
Last active March 3, 2024 21:48
Show Gist options
  • Save MrZenW/fc1f7ee6b0f7a61379d4d08e6d455b7c to your computer and use it in GitHub Desktop.
Save MrZenW/fc1f7ee6b0f7a61379d4d08e6d455b7c to your computer and use it in GitHub Desktop.
git-reset: The different ways to use git-reset

git-reset: The different ways to use git-reset

https://git-scm.com/docs/git-reset

https://www.gitkraken.com/learn/git/git-reset

### reset HEAD to a specified submit, and DISCARD the changes of the submit
# [ ✅ reset HEAD, ❌ stage changes(git add), ❌ keep workspace changes ]
git reset --hard <SUBMIT_CODE>

### reset HEAD to a specified submit, and KEEP the changes of the submit being staged(git add)
# [ ✅ reset HEAD, ✅ stage changes(git add), ❌ keep workspace changes ]
git reset --soft <SUBMIT_CODE>

### reset changes to be unstaged(NOT git add)
# [ ❌ reset HEAD, ❌ stage changes(git add), ✅ keep workspace changes ]
git reset <FILE_PATH>
# unstage all
git reset


### force push local change to remote
git push -f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment