git 工作区、暂存区和版本库
工作区:就是在你的计算机中能够看到的内容
暂存区:stage/index.一般存放在 .git目录下的 index 文件(.git/index)中,所以我们把暂存区有时也叫作索引(index)。
版本库:工作区有一个隐藏目录 .git ,这个就是git的版本库
git init 初始化仓库。
git status 查看仓库当前的状态,显示有变更的文件。
git add file 添加文件到暂存区。
添加一个或多个文件到暂存区:
git add file1 file2 ...
添加指定目录到暂存区,包括子目录:
git add dirname
添加当前目录下的所有文件到暂存区:
git add ./
git commit -m”注释” 将暂存区内容添加到仓库中,并添加注释。
git 查看提交历史
git log
查看简洁版本:
git log --oneline
查看什么时候出现了分支合并:
git log --oneline --graph
指定日期查看:
git log --oneline --before={3.weeks.ago} --after={2020-10-01} --no-merges
查看某个人的所有提交:
git log --author=”authorname”
eg:git log --author =”panda”
逆序查看所有提交:
git log --reverse
查看某个人总共提交的个数:
git log --author="authorname" --oneline | wc -l
eg: git log --author="panda" --oneline | wc -l
输出结果:13
查看某个人总共提交统计:
git log --author="jerry.deng" --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 }'
eg: git log --author="jerry.deng" --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 }'
输出结果:added lines: 226, removed lines: 1168, total lines: -942
查看指定文件的修改记录:
git blame filename