V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
otmb
V2EX  ›  程序员

在 github fork 一个项目之后,如何从原来项目获取最新的 update 呢?

  •  
  •   otmb · 2015-01-10 20:25:12 +08:00 · 3953 次点击
    这是一个创建于 3395 天前的主题,其中的信息可能已经有所发展或是发生改变。

    网页上好像没找到操作的按钮...

    14 条回复    2015-01-11 10:34:05 +08:00
    ijse
        1
    ijse  
       2015-01-10 20:33:02 +08:00
    我只知道在本地操作:
    git remote add originalRepo original-repo-git-url
    git pull originalRepo master

    git push myRepo master
    laobubu
        2
    laobubu  
       2015-01-10 20:39:22 +08:00   ❤️ 1
    貌似是这个 https://help.github.com/articles/syncing-a-fork/

    大意就是在本地使用类似 `git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git` 的方式添加原repo,
    然后 fetch upstream ,然后 merge upstream/master 到自己的 master 就可以了
    huoshanhui
        3
    huoshanhui  
       2015-01-10 20:44:03 +08:00
    只能从本地进行拉取。
    zhicheng
        4
    zhicheng  
       2015-01-10 20:44:10 +08:00
    LS 给出的添加一个新的 remote 是比较好的办法,还有另一个更简单一些的,就是发一个 Pull Request 给自己。
    jasontse
        5
    jasontse  
       2015-01-10 20:55:30 +08:00 via iPad
    @zhicheng
    那会污染 Commits 处女座看着不爽
    Mrun
        6
    Mrun  
       2015-01-10 20:56:26 +08:00
    xp0729
        7
    xp0729  
       2015-01-10 21:03:38 +08:00
    每次提交代码前都会fetch and merge,除了会让提交看起来比较乱以外暂时没什么缺点
    otmb
        8
    otmb  
    OP
       2015-01-10 21:05:08 +08:00
    @zhicheng 发一个 Pull Request 给自己,怎么弄?
    otmb
        9
    otmb  
    OP
       2015-01-10 21:17:07 +08:00
    @xp0729 手动敲命令么?赶脚好麻烦啊
    tonynothing
        10
    tonynothing  
       2015-01-10 21:20:57 +08:00
    @otmb 像Sourcetree和Tower这样的Git客户端都是可以添加Remote的,官方的用的不多不知道。
    yfdyh000
        11
    yfdyh000  
       2015-01-10 21:26:21 +08:00
    @jasontse 污染commits好像可以合并后本地fetch、reset、强制push吧。就只剩下pull request了。

    @otmb 6楼的链接,“如何让自己的项目与原作者的项目保持同步”。

    给自己发Pull的方法有一个重大的好处,就是如果变更集很大,本地合并需要拉取再推送,耗流量且很依赖网络速度。
    Rocko
        12
    Rocko  
       2015-01-10 22:23:48 +08:00
    pezy
        13
    pezy  
       2015-01-10 22:31:18 +08:00
    只用网页,可以参考这里: http://www.zhihu.com/question/20393785/answer/30725725
    airyland
        14
    airyland  
       2015-01-11 10:34:05 +08:00   ❤️ 1
    一直是PR
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2370 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 16:09 · PVG 00:09 · LAX 09:09 · JFK 12:09
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.