【问题标题】:git single user - several computers / repositoriesgit 单用户 - 多台计算机/存储库
【发布时间】:2018-10-22 12:53:47
【问题描述】:

我正在介绍 git,但目前我自己在 git 环境中工作。 我使用固定的虚拟服务器、本地虚拟服务器和笔记本电脑。我需要能够确定我在哪里进行了更改。怎么解决?

在后期我当然可能会介绍更多可以在 git 环境中工作的资源。

澄清一下:由于我是单个开发人员,因此跟踪提交/拉取/提取是从哪台机器完成对我来说更重要,而不是 user/user.email。

我应该像这样添加不同的用户凭据吗?

[user.email]

  • git config --global user.email "physical-server-1@company.com"
  • git config --global user.email "virtual-server-1@company.com"
  • git config --global user.email "local-virtual-server-2@company.com"
  • git config --global user.email "laptop@company.com"

[用户名]

  • git config --global user.name "physical-server-1"
  • git config --global user.name "virtual-server-1"
  • git config --global user.name "local-virtual-server-2"
  • git config --global user.name "laptop"

【问题讨论】:

  • 我不确定在哪台机器上进行更改是否应该重要。更改是否特定于特定机器?在这种情况下,您应该使用分支来跟踪特定于机器的代码库。
  • 为什么需要这个?您似乎在增加不必要的复杂性。

标签: git


【解决方案1】:

我能想到两种解决方案:

  1. 如上所述,使用单独的电子邮件/姓名
  2. 使用不同的私钥签署您的提交(每台机器一个)。见https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-22
    • 2011-05-07
    • 1970-01-01
    • 2011-12-31
    • 1970-01-01
    • 2011-06-16
    相关资源
    最近更新 更多