Git使用(一)

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

声明:本内容为作者独立观点,不代表电子星球立场。未经允许不得转载。授权事宜与稿件投诉,请联系:editor@netbroad.com
觉得内容不错的朋友,别忘了一键三连哦!
赞 5
收藏 3
关注 28
成为作者 赚取收益
全部留言
0/200
  • dy-DHzbiapC 2021-11-30 11:37
    希望多多更新
    回复