Skip to content

Instantly share code, notes, and snippets.

@marvingreenberg
Last active February 18, 2020 15:07
Show Gist options
  • Save marvingreenberg/0e7a4f51914ad1dd9308ec6a90644295 to your computer and use it in GitHub Desktop.
Save marvingreenberg/0e7a4f51914ad1dd9308ec6a90644295 to your computer and use it in GitHub Desktop.
git config --global alias.ci 'commit -v'
git reset --hard <commit> # careful, but roll the current branch back to earlier commit
git rev-list -n 1 <tagname> # show the commit associated with a tag
git tag -f 2.3.0 # Apply a tag
git push origin --all # push all branches (not just current)
git push origin --tags # push all tags
git diff --name-only SHA1 SHA2. # show just changed files between commits
git diff --name-only master # show just changed files from current branch to master
git reset # unstage all files you might have staged with git add
git checkout . # revert all local uncommitted changes (should be executed in repo root)
git checkout [some_dir|file.txt] # revert uncommitted changes only to particular file or directory
git reset --hard HEAD # revert all uncommitted changes (longer to type, but works from any subdirectory)
git clean -fdx # remove all local untracked files, so only git tracked files remain
WARNING: -x will also remove all ignored files, including ones specified by .gitignore!
git-revert[1] is about making a new commit that reverts the changes made by other commits.
git-restore[1] is about restoring files in the working tree from either the index or another commit.
This command does not update your branch. The command can also be used to restore files in the index
from another commit. Maybe simpler is 'git stash; git stash drop'
git-reset[1] is about updating your branch, moving the tip in order to add or remove commits from
the branch. This operation changes the commit history.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment