zoukankan      html  css  js  c++  java
  • 2016/01/11开始学习git:查看仓库状态和修改文件

    1.使用git status查看版本库的状态

    $ git status
    On branch master
    nothing to commit, working directory clean
    Git告诉我们当前没有需要提交的修改,而且,工作目录是干净(working directory clean)的。

    2.现在去修改readme.txt的内容

    原本内容为:

    Git is a version control system.
    Git is free software.

    修改后:

    Git is distributed a version control system.
    Git is free software.

    3.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")

    asus@asus-PC MINGW64 /e/learngit (master)
    看到提示readme.txt是modified,但是没有准备提交修改

    4.git diff readme.txt 查看readme.txt修改前后的差别

    asus@asus-PC MINGW64 /e/learngit (master)
    $ git diff readme.txt
    diff --git a/readme.txt b/readme.txt
    index d8036c1..487c372 100644
    --- a/readme.txt
    +++ b/readme.txt
    @@ -1,2 +1,2 @@
    -Git is a version control system.
    +Git is distributed a version control system.
     Git is free software.
    No newline at end of file

    asus@asus-PC MINGW64 /e/learngit (master)
    $
    看到新增的内容

    5. git add 、git commit 提交修改

    git add readme.txt

    git status

    asus@asus-PC MINGW64 /e/learngit (master)
    $ git status
    On branch master
    Changes to be committed:
      (use "git reset HEAD <file>..." to unstage)

            modified:   readme.txt


    asus@asus-PC MINGW64 /e/learngit (master)

    git commit -m "Add distributed"

    asus@asus-PC MINGW64 /e/learngit (master)
    $ git commit -m "Add distributed"
    [master 5e0e7b7] Add distributed
     1 file changed, 1 insertion(+), 1 deletion(-)

    asus@asus-PC MINGW64 /e/learngit (master)
    $

    6.git status查看

    asus@asus-PC MINGW64 /e/learngit (master)
    $ git status
    On branch master
    nothing to commit, working directory clean

    asus@asus-PC MINGW64 /e/learngit (master)
    $

  • 相关阅读:
    网上订餐系统后台代码bug记录与解决
    vector二维数组
    力扣-树-练习题(一)
    优先队列

    并查集
    C++进制转换函数
    平衡二叉树(AVL树)定义与基本操作
    二叉查找树练习题
    树的遍历
  • 原文地址:https://www.cnblogs.com/lao-wan/p/5123054.html
Copyright © 2011-2022 走看看