coolair
V2EX  ›  问与答

Git 如何为多个远程仓库配置不同的邮箱和用户名?

  •  
  •   coolair · Feb 6, 2017 · 2197 views
    This topic created in 3579 days ago, the information mentioned may be changed or developed.
    有一个自己的远程仓库,用的一个邮箱和用户名;
    一个是 GitHub 的,又是另一个邮箱和用户名。
    7 replies  •  2017-02-06 12:26:50 +08:00
    drush
    drush
    Feb 6, 2017
    1
    --local
    yinheli
    yinheli
    Feb 6, 2017❤️2
    2
    不行,邮箱 /提交者名称是作为 git 历史的一部分,修改用户名和邮箱都会导致重写历史, hash 值的改变。
    你的需求恐怕只能 filter-branch 来实现,可以做成脚本,修改仓库的用户名和邮箱。
    drush
    drush
    Feb 6, 2017
    3
    呃,我理解錯了,樓主請無視我
    curiousjude
    curiousjude
    Feb 6, 2017
    4
    一个本地仓库对应多个远程仓库?
    coolair
    coolair
    OP
    Feb 6, 2017
    5
    @curiousjude 嗯,我自己用阿里云搭了个 Git 服务器,后面想把这个项目放到 GitHub 上开源了,就又添加了一个远程仓库。但是, GitHub 上注册的邮箱和我正在用的不一样。
    vietor
    vietor
    Feb 6, 2017 via Android
    6
    目录里面单独配置
    yinheli
    yinheli
    Feb 6, 2017
    7
    @coolair 如果只是要推送到不同的远端服务器,不改变已有提交历史纪录的提交者名称和邮箱,通过 git remote add 命令增加一个远程仓库 https://git-scm.com/docs/git-remote#git-remote-emaddem
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2913 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 05:11 · PVG 13:11 · LAX 21:11 · JFK 00:11
    ♥ Do have faith in what you're doing.