Git 常用命令

66 阅读1分钟

查看所有分支

git branch -a

移除远程origin

git remote rm origin

添加远程origin

git remote add origin 仓库地址

git 配置代理

[http "https://github.com"]
        proxy = http://127.0.0.1:33210
[http "http://github.com"]
        proxy = http://127.0.0.1:33210

git删除已经push的提交

  1. git reset --hard <commit hash>
  2. git push --force-with-lease

git tag 相关

  • 添加本地标签 git tag <tagname>
  • 删除本地标签 git tag -d <tagname>
  • 查看本地标签列表 git tag
  • 查看远程标签列表 git ls-remote --tags origin
  • 提交本地所有标签 git push origin --tags
  • 提交本地某个标签 git push origin <tagname>

git 查看提交代码量

 git log --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git log --author="$name" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -; done