我有应用程序服务器,我使用Chef +一些特别的bash脚本引导在一起。问题是,当我想在这些应用服务器上运行更新时,我得到:

19:00:28: *** Please tell me who you are.

Run

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

我真的需要在每次更新应用服务器时设置简单的git pull origin master吗?是否有任何方法来覆盖这种行为,以便在没有设置姓名和电子邮件时不会出错?


当前回答

而不是做一个git拉,你可以做:

git fetch
git reset --hard origin/master

这两种方法都不需要配置git用户名/电子邮件。

这将破坏任何未提交的本地更改/提交,并将使HEAD指向一个提交(而不是一个分支)。但对于应用服务器来说,这两个都不是问题,因为您不应该进行本地更改或提交到该存储库。

其他回答

更新引导过程以创建${HOME}/。使用适当的内容,或者从某个地方复制一个现有的Gitconfig。

无法自动检测电子邮件地址。

默认情况下,它采用您的系统用户名,如abc@xyz.none。

所以你需要像下面这样设置你的邮箱:

git config user.email "someone@gmail.com"

设置email后,你可以运行git命令并提交你的更改。

git init Git add * Git commit -m "some init msg"

git config user.email "insert github email here"
git config user.name "insert github real name here"

这对我来说很有效。

如果你发现旧的默认行为很有用(即使用本地用户名和主机名作为作者标识,而不是识别你的人),你可以运行:

git config --global user.name "$USER" && git config --global user.email "$USER@$HOSTNAME"

要设置this/current repo的配置,只需删除——global并设置名称/电子邮件,如下所示:

$ git config user.name "John Doe" 
$ git config user.email "JohnDoe@gmail.com"