Config #
Get repository or global options #
git config --list
git config -l
Identity setup #
git config --global user.name "John Doe"
git config --global user.email [email protected]
you can also use --local
to use this identity only in the directory
git config --local user.name "John Doe"
git config --local user.email [email protected]
Remote #
#
git remote set-url origin <repo url>
Auto setup remote branch #
git config --global --add --bool push.autoSetupRemote true
Tag #
Push branch and tag
git push --follow-tags
Delete origin tag
git push --delete origin v0.1.3
Delete local tag
git tag -d v0.1.3
Commit #
Remove latest commit #
git reset HEAD^ --hard
Branch #
Reomve local branch #
git branch -D <branch>
Reomve remote branch #
git push --delete <remote> <branch>
Git Aliases #
git config --global alias.br branch
git config --global alias.co checkout
git config --global alias.cp cherry-pick
git config --global alias.sp stash pop
git config --global alias.st stash
git config --global alias.pl pull
git config --global alias.ps push
Reset author information for all commits #
for all branch
git filter-branch -f --env-filter '
GIT_AUTHOR_NAME='ShihTingJustin'
GIT_AUTHOR_EMAIL='[email protected]'
GIT_COMMITTER_NAME='ShihTingJustin'
GIT_COMMITTER_EMAIL='[email protected]'
' -- --all
you could also use HEAD
git filter-branch -f --env-filter '
GIT_AUTHOR_NAME='ShihTingJustin'
GIT_AUTHOR_EMAIL='[email protected]'
GIT_COMMITTER_NAME='ShihTingJustin'
GIT_COMMITTER_EMAIL='[email protected]'
' HEAD
src: https://git-scm.com/docs/git-filter-branch
Why are my contributions not showing up on my profile? #
make sure the email setting in git config is as same as GitHub email
git config user.email
or read GitHub Doc