删除远程分支

1
2
# 删除远程分支 xxx
git push origin :xxx

统计提交者的 commit 数量

1
git shortlog -sn

删除某一次 commit

1
git revert --strategy resolve <commit>

git diff 中文乱码

在命令行下输入以下命令:

最后一条命令是因为 git log 默认使用 less 分页,所以需要 bash 对 less 命令进行 utf-8 编码
想长期生效的 话要改profile添加环境变量

1
2
3
4
5
git config --global core.quotepath false          # 显示 status 编码
git config --global gui.encoding utf-8 # 图形界面编码
git config --global i18n.commit.encoding utf-8 # 提交信息编码
git config --global i18n.logoutputencoding utf-8 # 输出 log 编码
export LESSCHARSET=utf-8

git更新 commit author

1
2
3
4
5
git filter-branch --env-filter '
if [ "$GIT_AUTHOR_NAME" = "Old Name" ]; then \
export GIT_AUTHOR_NAME="New Name" GIT_AUTHOR_EMAIL="new@mail.com"; \
fi
'

Git tags

List tags

To list all tags, use the following command.

1
git tag

创建 Tags

Git uses two main types of tags: lightweight and annotated.

lightweight tag

1
git tag <tagname>  

annotated tag

To create an annotated tag in Git you can just run the following simple commands on your terminal.

1
2
3
4
5
$ git tag -a v2.1.0 -m "xxx feature is released in this tag."
$ git tag
v1.0.0
v2.0.0
v2.1.0

Push Tag

To push particular tag you can use below command:

1
git push origin v1.0.9

删除tag

1
2
3
4
$ git tag -d v1.0
Deleted tag 'v1.0' (was 808b598)

$ git push --delete origin v1.0