大佬教程收集整理的这篇文章主要介绍了Git 系列教程(5)- 记录每次更新到仓库,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
你工作目录下的每一个文件只有两种状态:tracked 或 untracked
可以用 git status@H_673_55@ 命令查看哪些文件处于什么状态。 如果在克隆仓库后立即使用此命令,会看到类似这样的输出:
@H_675_59@git status On branch master Your branch is up-to-date with 'origin/master'@H_675_59@. nothing to commit,working directory clean
在项目下创建一个新的 README@H_673_55@ 文件,使用
git status@H_673_55@ 命令,将看到一个新的 untracked 文件
@H_675_59@echo @H_735_63@my Project' >@H_675_59@ README $ git status On branch master Your branch is up-to-@H_675_59@. Untracked files: (use "git add <file>..." to include @H_675_59@in@H_675_59@ what will be committed) README nothing added to commit but untracked files present (use git add" to track)
如果修改了一个名为 CONTRIBUTinG.md@H_673_55@ 的已被 tracked 的文件,然后运行
git status@H_673_55@ 命令,会看到下面内容
@H_675_59@git reset HEAD <file>...file@H_675_59@: README Changes not staged @H_675_59@for@H_675_59@ commit: (use to update what will be committed) (use git checkout -- <file>..." to discard changes @H_675_59@ working directory) modified: CONTRIBUTinG.md
CONTRIBUTinG.md@H_673_55@ 出现在 Changes not staged for commit@H_673_55@ 这行下面,说明已跟踪文件的内容发生了变化,但还没有放到暂存区
git add@H_673_55@ 命令
运行 git add@H_673_55@ 将“CONTRIBUTinG.md”放到暂存区,然后再看看
git status@H_673_55@ 的输出:
@H_675_59@$ git add CONTRIBUTinG.md $ git status On branch master Your branch is up-to-@H_675_59@: README modified: CONTRIBUTinG.md
修改 README 文件后暂存,然后编辑 CONTRIBUTinG.md@H_673_55@ 文件后先不暂存, 运行
status@H_673_55@ 命令将会看到:
@H_675_59@$ git status On branch master Your branch is up-to-@H_675_59@ to unstagE) modified: README Changes not staged @H_675_59@ working directory) modified: CONTRIBUTinG.md
要查看尚未暂存的文件更新了哪些部分,不加参数直接输入 git diff@H_673_55@:
$ git @H_675_59@diff @H_675_59@diff --git a/CONTRIBUTinG.md b/@H_675_59@CONTRIBUTinG.md index 8ebb991..643e24f 100644 --- a/@H_675_59@CONTRIBUTinG.md +++ b/@H_675_59@CONTRIBUTinG.md @@ -65,7 +8@H_675_59@ @@ branch directly,things can get messy. Please include a @H_675_59@nice@H_675_59@ description of your changes when you submit your PR; @H_675_59@if we have to read the whole @H_675_59@diff to figure out why youre contribuTing @H_675_59@in the first place,youre less likely to get @L_696_78@BACk and have your change -merged @H_675_59@. +merged @H_675_59@in. Also,@H_675_59@split your changes into comprehensive chunks @H_675_59@if your @H_675_59@patch@H_675_59@ is +@H_675_59@longer than a dozen lines. If you are starTing to work on a particular area,feel @H_675_59@free@H_675_59@ to submit a PR that highlights your work @H_675_59@in progress (and note @H_675_59@in the PR title that its
$ git @H_675_59@diff --@H_675_59@staged @H_675_59@diff --git a/README b/@H_675_59@README new @H_675_59@file mode 100644@H_675_59@ index 0000000@H_675_59@..03902a1 --- /dev/@H_675_59@null +++ b/@H_675_59@README @@ -0,1)">0 +1@H_675_59@ @@ +My Project
像之前说的,暂存 CONTRIBUTinG.md@H_673_55@ 后再编辑,可以使用
git status@H_673_55@ 查看已被暂存的修改或未被暂存的修改。 如果我们的环境(终端输出)看起来如下:
@H_675_59@$ git add CONTRIBUTinG.md $ @H_675_59@# test line' >>@H_675_59@ CONTRIBUTinG.md $ git status On branch master Your branch is up-to-@H_675_59@ to unstagE) modified: CONTRIBUTinG.md Changes not staged @H_675_59@ working directory) modified: CONTRIBUTinG.md
以上是大佬教程为你收集整理的Git 系列教程(5)- 记录每次更新到仓库全部内容,希望文章能够帮你解决Git 系列教程(5)- 记录每次更新到仓库所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。