博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Git 提交修改内容和查看被修改的内容
阅读量:4323 次
发布时间:2019-06-06

本文共 1683 字,大约阅读时间需要 5 分钟。

我们将仓库里的readme.txt文件修改一下,改成如下内容:

Git is a distributed version control system

Git is free software.

运行git status命令查看一下结果:

$ git status

On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: readme.txt

no changes added to commit (use "git add" and/or "git commit -a")

git status命令可以让我们时刻的掌握仓库的当前状态,上面的信息告诉我们,readme.txt被修改过了,但是还没有准备提交修改

Git虽然告诉我们readme.txt被修改了,但是如果能看到修改了什么内容就是最好的了,好比你忘记了上次怎么修改的readme.txt,

这时候你就要用 git diff这个命令看看:

$ git diff readme.txt

diff --git a/readme.txt b/readme.txt
index 58998b5..9c3f69a 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,2 +1,2 @@
-Git is a version control system
+Git is a distributed version control system
Git is free software.
\ No newline at end of file

git diff 顾名思义就是查看difference,显示格式正是Unix通用的diff格式,可以从上面的输出信息看出,第一行添加了一个"distributed"单词。

知道了对readme.txt作了什么修改后,再把它提交到仓库就放心多了,提交修改和提交新文件是一样的,分add和commit两步:

LV@LV-PC MINGW32 /c/gitRespository (master)

$ git add readme.txt            //添加修改的文件

LV@LV-PC MINGW32 /c/gitRespository (master)

$ git status                 //当前仓库的状态:将要被提交的修改包括readme.txt
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

modified: readme.txt

LV@LV-PC MINGW32 /c/gitRespository (master)
$ git commit -m "modify the readme.txt commit"  //提交
[master 4b1d71b] modify the readme.txt commit
1 file changed, 1 insertion(+), 1 deletion(-)

LV@LV-PC MINGW32 /c/gitRespository (master)

$ git status              //当前仓库状态:没有需要提交的修改,工作目录是干净的
On branch master
nothing to commit, working directory clean

转载于:https://www.cnblogs.com/LvLoveYuForever/p/5492449.html

你可能感兴趣的文章
[bzoj3944] Sum
查看>>
hadoop2.7节点的动态增加与删除
查看>>
Ogre: 天空
查看>>
关于NSDictionary的一点感悟
查看>>
CSS长度单位:px和pt的区别
查看>>
50.分治算法练习: 二分算法: 2703 奶牛代理商 XII
查看>>
Wampserver 403问题
查看>>
mysql日志详细解析
查看>>
解决关闭app权限弹框后无法识别页面对象问题
查看>>
struts2_对Map进行双层迭代
查看>>
asp.net是什么?asp.net、vb.net和c#.net有什么区别?
查看>>
PhotoView
查看>>
hdu 1735(贪心) 统计字数
查看>>
iOS 系统框架结构图
查看>>
uml系列(六)——行为图:活动&状态
查看>>
Learning Deconvolution Network for Semantic Segme小结
查看>>
Leetcode 424.替换后的最长重复字符
查看>>
第二阶段:2.商业需求文档MRD:1.M版本管理
查看>>
我爱Java系列---【单列集合和双列集合总结】
查看>>
新开始
查看>>