Git是一个免费的开源分布式版本控制系统,旨在以快速和高效的方式处理从小型到超大型项目的所有内容。Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
安装git 打开Git官网https://git-scm.com/downloads 选择你所使用的操作系统,下载安装即可。
git简单配置 1 2 3 4 5 6 7 8 9 git config user.name git config user.email git config --global user.name "your name" git config --global user.email "your email"
git基础操作 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 git pull origin <branch> git push origin <branch> git branch -a git checkout <branch> git branch -d <branch> git push -u <branch> git push origin --delete <branch-name> git switch <branch> git checkout -- <file> git add <file> git reset HEAD <file> git merge --no-ff -m <commit>
git stash 1 2 3 4 5 6 7 8 9 10 11 git stash git stash save "" git stash apply git stash pop
git reset 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 git reset --hard HEAD^ git reset --hard HEAD~<num> git reset --hard <commitId> git commit --amend git reset --soft HEAD^ git reset --soft HEAD~<num> git reset --mixed HEAD^ git reset HEAD^ git reset --mixed HEAD~<num> git reset HEAD~<num>
git log 1 2 3 4 5 6 7 8 9 10 11 git log git reflog git log --author="willxup" --since='2020-01-01' --until ='2023-12-31' --pretty=tformat: --numstat | gawk '{ add += $1 ; subs += $2 ; loc += $1 - $2 } END { printf "增加的行数:%s 删除的行数:%s 总行数: %s\n",add,subs,loc }' git log --author="willxup" --pretty=tformat: --numstat | gawk '{ add += $1 ; subs += $2 ; loc += $1 - $2 } END { printf "增加的行数:%s 删除的行数:%s 总行数: %s\n",add,subs,loc }'
git cache
gitstats工具
GitStats 是git(分布式版本控制系统)存储库的统计生成器。它检查存储库并从其历史记录中生成一些有趣的统计数据。目前 HTML 是唯一的输出格式。
官网地址:https://gitstats.sourceforge.net/ github地址:https://github.com/hoxu/gitstats
gitstats可以生成整个git项目的统计,是一个非常实用的小工具。
项目依赖
Windows安装
下载python2 ,gitstats使用python启动,安装后需要设置环境变量 。
python2安装工具可以帮助添加,在安装时可以选择(gitstats只适用于python2)
下载gnuplot ,gitstats使用gnuplot生成图表,安装后需要设置环境变量 。
Windows环境下:高级系统设置->系统属性->环境变量->系统变量->Path -> 例如增加D:\gnuplot\bin
下载gitstats ,下载源码即可。解压源码后,将文件gitstats复制一份出来并改名为gitstats.py。
其他方式安装 Mac/Linux使用软件管理工具进行安装,比较简单,参考官方文档 即可,过程与windows安装类似。
使用方法
在gitstats目录下打开命令行工具(推荐git bash)
执行以下命令生成git项目统计结果
1 2 python gitstats.py /c/project-name /c/gitstats/project-name
生成完毕后,进入输出目录,运行index.html即可。