V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
git
Pro Git
Atlassian Git Tutorial
Pro Git 简体中文翻译
GitX
MajestySolor
V2EX  ›  git

一个本地 git 仓库,如何同时连接多个远程仓库来达到 push 时同步的效果?

  •  
  •   MajestySolor · 2014-11-04 03:12:48 +08:00 · 9959 次点击
    这是一个创建于 3467 天前的主题,其中的信息可能已经有所发展或是发生改变。
    比如主要使用github,但想在coding.net上做个国内镜像备份
    21 条回复    2014-11-04 15:42:04 +08:00
    xcv58
        1
    xcv58  
       2014-11-04 03:19:55 +08:00
    git remote add ?
    yfdyh000
        2
    yfdyh000  
       2014-11-04 03:24:57 +08:00
    MajestySolor
        3
    MajestySolor  
    OP
       2014-11-04 03:40:43 +08:00
    @xcv58
    @yfdyh000

    感谢回复
    我用 git remote add 分别连接了github和coding.net,但是push的时候要分开输入帐号密码,如何设置能以后不再问我要帐号密码呢,git 菜鸟头有点晕~~
    jybox
        4
    jybox  
       2014-11-04 03:56:42 +08:00   ❤️ 1
    msg7086
        5
    msg7086  
       2014-11-04 04:12:35 +08:00   ❤️ 1
    @MajestySolor 用SSH连接,不要用HTTPS。coding默认就塞https让我感到很心塞。
    xcv58
        6
    xcv58  
       2014-11-04 04:34:12 +08:00   ❤️ 1
    @MajestySolor 你不用 key 吗?
    lightening
        7
    lightening  
       2014-11-04 04:39:29 +08:00   ❤️ 1
    @msg7086 GitHub 现在推荐使用 HTTPS 了。https://help.github.com/articles/which-remote-url-should-i-use/

    如何在 HTTPS 下将密码存入操作系统 keychain: https://help.github.com/articles/caching-your-github-password-in-git
    MajestySolor
        8
    MajestySolor  
    OP
       2014-11-04 04:39:39 +08:00
    @jybox
    @msg7086
    @xcv58

    理解了,感谢各位帮助 :)
    MajestySolor
        9
    MajestySolor  
    OP
       2014-11-04 05:40:21 +08:00
    @xcv58
    @jybox

    请问我生成了ssh密钥,在github网站上也添加了,但是每次push还是要我输入passphrase是为什么呢?

    msg7086
        11
    msg7086  
       2014-11-04 06:03:26 +08:00
    @lightening 但是好像没看到推荐HTTPS的理由……
    MajestySolor
        12
    MajestySolor  
    OP
       2014-11-04 06:48:35 +08:00
    @xcv58 非常感谢
    networm
        13
    networm  
       2014-11-04 07:29:27 +08:00 via iPad
    生成 SSH key 的时候不要输密码,直接按回车跳过
    dsdshcym
        14
    dsdshcym  
       2014-11-04 08:05:44 +08:00
    @msg7086 These URLs work everywhere
    Oishi
        15
    Oishi  
       2014-11-04 08:31:23 +08:00
    @msg7086 These URLs work everywhere--even if you are behind a firewall or proxy.
    boom11235
        16
    boom11235  
       2014-11-04 09:41:27 +08:00
    @lightening 为什么推荐使用HTTPS啊?
    xcv58
        17
    xcv58  
       2014-11-04 10:17:09 +08:00
    @MajestySolor 客气。
    wesley
        18
    wesley  
       2014-11-04 11:11:37 +08:00
    git可以把账号密码保存到本地文件中,不用key也行
    linux下是 ~/.netrc
    win下是 我的文档/_netrc

    文件内容像这样:
    machine git.oschina.net
    login you git account
    password your password
    mingzhi
        19
    mingzhi  
       2014-11-04 11:57:47 +08:00
    我的做法是非常dirty:
    直接改.git/config 文件
    在 remote "origin" 加url = "..."
    jsq2627
        20
    jsq2627  
       2014-11-04 14:48:13 +08:00
    我也看到现在很多地方推荐说用HTTPS,有点不解。
    HTTPS也是有办法保存密码的: https://help.github.com/articles/caching-your-github-password-in-git/

    最后还是推荐用图形客户端。
    lightening
        21
    lightening  
       2014-11-04 15:42:04 +08:00 via iPhone
    @mingzhi
    @boom11235
    HTTP 对防火墙通过率高,另外性能好。也方便调用其他的 web 接口来提供一些其他功能。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   776 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 21:07 · PVG 05:07 · LAX 14:07 · JFK 17:07
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.