kuniga.me > Docs > Git Cheatsheet
git checkout -- <file>git reset --hard HEAD~1NOTE: this doesn’t remove untracked files
git checkout .git clean -fd# (optional) first, see what files will be purged
git clean -n
# purge
git clean -fdgit stash -- <file>git stash popCreates new branch foo:
git branch fooChanges to branch foo:
git checkout fooList existing branches:
git branchDelete branch foo (move away from it first):
git branch -d fooAdd new remote repo shorcut/alias. For example, I want public to refer to the repository at git@github.com:kunigami/my-repo.git.
git remote add public git@github.com:kunigami/my-repo.gitList remote repos associated to this local repo:
git remote -vSend changes to a remote repo + branch, for example, the remote repository aliased as origin, branch test:
git push origin test“Pull” remote branch (e.g. my_remote_branch) that does not exist in your local repo and switch to it. Note: this only works if my_remote_branch only appears in exactly one of the remote repos:
git switch my_remote_branchMark file as resolved:
git add <filemame>