• [git 学习篇] git commit原理 --实践体会


    1 现对readme.txt作出修改,增加一行内容: Git has a mutable index called stage.

    Git is a distributed version control system.
    Git is free software distributed under the GPL.
    Git has a mutable index called stage.

    2 在工作区新添加一个文件:LICENSE文本文件(内容随便写)

    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
    #
    # Untracked files:
    #   (use "git add <file>..." to include in what will be committed)
    #
    #       LICENSE
    no changes added to commit (use "git add" and/or "git commit -a")

    Git非常清楚地告诉我们,readme.txt被修改了,而LICENSE还从来没有被添加过,所以它的状态是Untracked

    4 git add readme.txt  git add LICENSE( 没有执行git commit)

    现在,使用两次命令git add,把readme.txtLICENSE都添加后,用git status再查看一下:

    $ git status
    # On branch master
    # Changes to be committed:
    #   (use "git reset HEAD <file>..." to unstage)
    #
    #       new file:   LICENSE
    #       modified:   readme.txt
    # 
    git add 就是将文件修改放到存储区

    5 执行git commit

    执行git commit就可以一次性把暂存区的所有修改提交到分支。

    $ git commit -m "understand how stage works"
    [master 27c9860] understand how stage works
     2 files changed, 675 insertions(+)
     create mode 100644 LICENSE
  • 相关阅读:
    thinkphp3.2生成二维码
    php实现图片下载
    yii2.0 Activeform表单部分组件使用方法
    Yii2美化confirm
    Yii2学习笔记之场景
    tp5页面输出时,搜索后跳转下一页的处理
    php页面输出时,js设置input框的选中值
    mac中使用rz,sz上传文件
    golang的命令行程序开发
    Sring MVC基于Java Config方式配置Mybatis, 无XML
  • 原文地址:https://www.cnblogs.com/liuzhipenglove/p/7068520.html
Copyright © 2020-2023  润新知