设置 msysgit port 的用户名和电子邮件
我正在使用 msysgit 进行学校项目,这样我就可以在学校未安装它的计算机上进行提交等操作。
现在,当他们安装 git 时所做的第一件事就是按照自己喜欢的方式设置 .gitconfig。但是,由于我不能依赖计算机的 %HOME% 目录来获取相关文件,因此可以使用 --system 而不是 --global 来执行 git config 命令吗?
主要设置当然是user.name和user.email。使用 --system 是否适用于这些和所有其他类似的设置?它会将其保存到我的 USB 驱动器上安装 git 的 etc 目录的 gitconfig 中吗?
I'm using msysgit for a school project so I can do commits and such while on the computers at school which do not have it installed.
Now the first thing one does when they install git is set up their .gitconfig how they like. However, since I cannot rely on the %HOME% directory of the computer to have the relevant file would using --system instead of --global for the git config command work?
The main settings of course would be user.name and user.email. Would using --system work for those and all other similar settings? Would it save it to the gitconfig of the etc directory where git is installed on my USB drive?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您不必期望 .gitconfig 存在。它将在您设置用户名和电子邮件配置时创建。便携式版本的自述文件建议您也使用
--global
选项设置配置。You don't have to expect the .gitconfig to exist. It will be created when you set the user name and email configurations. The README for the portable version recommends that you set the config with
--global
option too.为自己添加一个脚本到拇指驱动器,该脚本将设置您想要的配置值(根据其他响应)。然后只需一行操作即可设置所有值。
Add yourself a script to the thumb drive that will set the config values you want (as per other responses). Then it's a one line action to set up all your values.
据我从这个 msysgit 问题的讨论中可以看出(尤其是评论 6 以及导致该结果的原因)你应该能够做你所描述的事情。使用
--system
而不是--global
和git config add user.name ...
等。这将修改安装的etc/
目录中的 gitconfig 文件。 (或者只是手动修改它,如果您有其他想要从您通常使用的标准文件(如果有的话)中继承的内容)这是我能看到的唯一方法,它仍然可以干净地尊重任何其他相关的 gitconfig 文件(就像每个项目的那样)。然后你就可以像在正常情况下一样使用常规的 git 命令。
请注意,虽然通常
--system
指的是/etc/gitconfig
,但在便携式安装的情况下,它指的是etc/< 中的 gitconfig 文件。 /code> 安装目录。
As far as I can tell from the discussion of this msysgit issue (especially comment 6 and what leads up to it) you should be able to do what you described. Use
--system
instead of--global
withgit config add user.name ...
and the like. That would modify the gitconfig file in theetc/
directory of the install. (or just modify it by hand, if you have other things you'd like to carry over from whatever standard one you usually use, if any)That's the only way I can see that would still also cleanly honor any other relevant gitconfig files (like per-project ones). Then you can just use regular git commands like you would in a normal situation.
Note that while usually
--system
refers to/etc/gitconfig
, in the case of a portable install, it refers to the gitconfig file in theetc/
directory of the install.我相信这篇文章描述了如何实现您想要做的事情:
http://markashleybell.com/portable-git-windows-setting -home-environment-variable.html
I believe this post describes how to achieve what you're trying to do:
http://markashleybell.com/portable-git-windows-setting-home-environment-variable.html