码迷,mamicode.com
首页 > 其他好文 > 详细

Git初始化之思考是谁完成的提交

时间:2014-12-15 00:17:32      阅读:258      评论:0      收藏:0      [点我收藏+]

标签:style   ar   color   os   使用   sp   strong   on   文件   

前面一开始先为Git设置了全局配置变量 user.name 和 user.email,如果不设置会有什么结果呢?执行下面的命令,删除Git全局配置文件中关于user.nameuser.email的设置:

$ git config --unset --global user.name
$ git config --unset --global user.email

这样一来,关于用户姓名邮件的设置都被清空了,执行下面的命令将看不到输出:

$ git config user.name
$ git config user.email

下面再尝试一次提交,看看是什么情况?在下面的命令中使用 --allow-empty 参数,这是因为如果没有对工作区的文件进行任何修改,Git默认不会执行提交,使用 --allow-empty 参数后允许执行空白提交注:删除了user.name,user.email后好像也都不能提交!!),操作如下:

$ cd /path/to/my/workspace/demo
$ git commit --allow-empty -m "who does commit?"
*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account‘s default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got ‘fuhd@fhd-xps.(none)‘)

仔细看看上面的执行 git commit 命令后的输出,原来Git提供了详细的帮助来告诉我们如何设置必需的配置变量。

我们再来看看版本库的提交日志

$ git log --pretty=fuller
commit 57ceaad77f3d61cb330f99779b9df52adb835be8
Author:     fuhd <001fhd@163.com>
AuthorDate: Thu Dec 11 19:30:23 2014 +0800
Commit:     fuhd <001fhd@163.com>
CommitDate: Thu Dec 11 19:30:23 2014 +0800

    initlalized.

提交者的信息是由之前设置的配置变量user.name和user.email给出的。

Git初始化之思考是谁完成的提交

标签:style   ar   color   os   使用   sp   strong   on   文件   

原文地址:http://my.oschina.net/fhd/blog/356050

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!