zoukankan      html  css  js  c++  java
  • git 基本操作----git commit 、配置用户信息

    git commit

    使用 git add 命令将想要快照的内容写入缓存区, 而执行 git commit 将缓存区内容添加到本地仓库中。

    Git 为你的每一个提交都记录你的名字与电子邮箱地址,所以第一步需要配置用户名和邮箱地址。

    注意,这里配置的用户名与邮箱,只是为了标识用户,不做任何验证作用。

    $ git config --global user.name 'runoob'
    $ git config --global user.email test@runoob.com

    接下来我们写入缓存,并提交对 hello.php 的所有改动。在首个例子中,我们使用 -m 选项以在命令行中提供提交注释。

    $ git add hello.php
    $ git status -s
    A  README
    A  hello.php
    $ git commit -m '第一次版本提交'
    [master (root-commit) d32cf1f] 第一次版本提交
     2 files changed, 4 insertions(+)
     create mode 100644 README
     create mode 100644 hello.php

    现在我们已经记录了快照。如果我们再执行 git status:

    $ git status
    # On branch master
    nothing to commit (working directory clean)

    以上输出说明我们在最近一次提交之后,没有做任何改动,是一个"working directory clean:干净的工作目录"。

    如果你没有设置 -m 选项,Git 会尝试为你打开一个编辑器以填写提交信息。 如果 Git 在你对它的配置中找不到相关信息,默认会打开 vim。屏幕会像这样:

    # Please enter the commit message for your changes. Lines starting
    # with '#' will be ignored, and an empty message aborts the commit.
    # On branch master
    # Changes to be committed:
    #   (use "git reset HEAD <file>..." to unstage)
    #
    # modified:   hello.php
    #
    ~
    ~
    ".git/COMMIT_EDITMSG" 9L, 257C

    如果你觉得 git add 提交缓存的流程太过繁琐,Git 也允许你用 -a 选项跳过这一步。命令格式如下:

    git commit -a

    我们先修改 hello.php 文件为以下内容:

    <?php
    echo '菜鸟教程:www.runoob.com';
    echo '菜鸟教程:www.runoob.com';
    ?>
     

    再执行以下命令:

    git commit -am '修改 hello.php 文件'
    [master 71ee2cb] 修改 hello.php 文件
     1 file changed, 1 insertion(+)
     
  • 相关阅读:
    一般性能指标
    Spring之AOP框架
    关于电子商务网站
    超级省代码的TAB选项卡
    sql递归
    程序员必备工具,程序员专用工具,程序员专用搜索
    类拟google那样的图片载入
    创建脚本编辑器
    Ancher常用的三种三栏网页宽度自适应布局方法
    js日期加天数
  • 原文地址:https://www.cnblogs.com/superxuezhazha/p/12987940.html
Copyright © 2011-2022 走看看