- Published on
Git Command Cheatsheet
Configure an alias
git config --global alias.acp '!f() { git add -A && git commit -m "$@" && git push; }; f'
List all variables in the config file git config -l
Update a global alias
As with any other config option you can set the value, replacing the old one, by running git config --global alias.st <value here>
. The problem you're running into is that when you want spaces in the value you're setting, you need to use quotes:
git config --global alias.st "diff --stat"
List all configured aliases
git config --get-regexp alias
Remove an alias
git config --global --unset alias.NAME
Remove file from Git Version Control
Remove a file from git tracking without deleting it from the working directory
git rm --cached filename
Reset current staging index and working directory back to the HEAD or any other commit
git reset HEAD/<commit-id>
Delete a remote branch
git push <remote> --delete <branch>
For example:
git push origin --delete fix/authentication````