coolair
V2EX  ›  问与答

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

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