我们将仓库里的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

Git 提交修改内容和查看被修改的内容的更多相关文章

  1. git提交时支持文件名大小写的修改

    在windows环境下,git提交文件时,默认对文件名大小写不敏感,若修改了文件名字的大小写,可能会导致提交时没有记录,文件名修改不成功.网上搜集了几种解决方法,现总结下: 1. 修改git conf ...

  2. Git使用、Git配置、Git提交代码、Git上传

    非教程,只是自己的一个简单笔记.建议没有入门的朋友,直接看git的官方help文档: https://help.github.com/articles/set-up-git 1.注册一个git账号,超 ...

  3. git提交到分支

    git checkout grego@gregoo:mygo$ git checkout origin/test Note: checking out 'origin/test'. You are i ...

  4. 6.Git内容修改之后的查看和提交

    我们已经成功地添加并提交了一个readme.txt文件,现在,是时候继续工作了,于是,我们继续修改readme.txt文件,改成如下内容: Git is a distributed version c ...

  5. 怎么修改git提交过的内容

    git修改历史提交   Git使用amend选项提供了最后一次commit的反悔.但是对于历史提交呢,就必须使用rebase了. git rebase -i HEAD~3 表示要修改当前版本的倒数第三 ...

  6. git使用diff----git-pull之后如何查看拉下来的文件有那些修改

    git pull拉取 git pull对于拉下来的修改文件自动对其进行git add /rm 及git commit 操作.所以拉下来的文件有那些修改,查看的方式可把它们归结于上一次提交的比较. gi ...

  7. git push撤销、git commit 撤销、git add撤销、修改git提交信息

    原文地址:http://leisure.wang/?p=472 虽然自觉是一个Git工具的老手了,但是平时犯了一点错误,就发现有点捉襟见肘了.就好像今天我把一些代码玩坏了,想撤回到前几个版本去(此时已 ...

  8. git 学习笔记 —— 获取远端分支并修改后提交至远端仓库

    笔者最近进行开发过程中,所有参与者的代码需要通过 git 上传到远端仓库中,不同的模块对应不同的 git 分支,不同模块的数据需要从远端仓库中获取.这里记录下笔者从远端仓库中获取分支数据,进行修改,最 ...

  9. Git查看并修改name和email

    显示name的方法: git config user.name git config --list 或者查看~/.gitconfig文件. 改名字: git config --global user. ...

随机推荐

  1. iOS 导航栏 不透明

    UINavigationBar.appearance().translucent = false UINavigationBar.appearance().barStyle = UIBarStyle. ...

  2. Git Github jekyll,gem Liquid模板语言 Markdown

    Git Git教程  常用 Git 命令清单   Git远程操作详解  使用jekyll建立个人网站 Git is a free and open source distributed version ...

  3. js的日期、定时器

    第一.js的日期 js的日期是用内置对象Date来操作,首先先创建一个日期 var date=new Date();,然后就可以调用它的API来获取年月日.时分秒等等,这不是本文重点,本文重点讲如何把 ...

  4. fpSpread 设置Border 样式

    // Create a new bevel border. //FarPoint.Win.BevelBorder bevelbrdr = new FarPoint.Win.BevelBorder(Fa ...

  5. Android(对话框)

    一.消息对话框 所谓的消息对话框,就是说当你点击按钮弹框,它会弹出一个消息提示你,消息对话框有相应的确定.取消.其他按钮,比如下方: 代码: //消息提示框 public void testOne(V ...

  6. 给hexo添加评论系统

    默认主题 landscape 文件目录,comments为新建的 _config.yml layout -- _partial -- article.ejs |- comments -- disqus ...

  7. 在Ubuntu 14.04安装 Let’s Encrypt并配置ssl

    1.下载安装 Let's Encrypt客户端 cd /usr/local/sbin sudo wget https://dl.eff.org/certbot-auto 2.添加执行权限 sudo c ...

  8. Solr搜索技术

    Solr搜索技术 今日大纲 回顾上一天的内容: 倒排索引 lucene和solr的关系 lucene api的使用 CRUD 文档.字段.目录对象(类).索引写入器类.索引写入器配置类.IK分词器 查 ...

  9. Generating Faces with Deconvolution Networks

    用深度学习做人脸合成,website:https://zo7.github.io/blog/2016/09/25/generating-faces.html 受启发于 Learning to Gene ...

  10. php 函数积累第一天

    htmlspecialchars 函数格式化表单输入的转化为html形式 exit - 输出一个消息并且退出当前脚本 list() 用一步操作给一组变量进行赋值. <?php$info = ar ...