Skip to content

Instantly share code, notes, and snippets.

@vurdalakov
Last active November 20, 2023 04:18
Show Gist options
  • Save vurdalakov/969a2e0197f541e2a67520eb6c34a29e to your computer and use it in GitHub Desktop.
Save vurdalakov/969a2e0197f541e2a67520eb6c34a29e to your computer and use it in GitHub Desktop.
Git cheatsheet

Remove last commit from local Git repository

git reset HEAD^

Remove last commit from remote Git repository

# remove commit locally
git reset HEAD^
# force-push the new HEAD commit
git push origin +HEAD

Remove last commit from remote Git repository but keep it locally

git push origin +HEAD^:<name of your branch, most likely 'master'>

Clone recursively without history

git clone --recursive --depth 1 -b master <repository url>

Show commit history

git log --pretty=format:"%h %ad [%an] %s" --date=short

List stashes in all submodules

git submodule foreach "git stash list"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment