根据父文件夹在一台机器上设置两个 git 帐户

setting up two git accounts on one machine based on parent folder

我公司使用 atlassian 套件进行工作。对于个人项目,我使用 github。我希望能够做的是让我的个人 git 帐户与 home/personal 相关联,并将我的工作 git 与 home/work 相关联,但我没有看到任何好的方法去做这个。我已经看到关于将 ssh 与两个 github 在线帐户一起使用的建议,这在我的情况下不起作用(我相信)。

如果这不可能,大多数人在这种情况下会做什么?目前我的 git config --global 设置与我的工作信息相关联。非常感谢任何帮助。

Git stores configuration options in three separate files, which lets you scope options to individual repositories, users, or the entire system:

  • <repo>/.git/config – Repository-specific settings .
  • ~/.gitconfig – User-specific settings. This is where options set with the --global flag are stored.
  • $(prefix)/etc/gitconfig – System-wide settings.

ref: https://es.atlassian.com/git/tutorials/setting-up-a-repository/git-config


usage: git config [options]

Config file location
    --global              use global config file
    --system              use system config file
    --local               use repository config file

因此您应该使用 2 个不同的 os 用户或分别配置每个存储库