美文网首页
git 更新远程仓库至folk仓库

git 更新远程仓库至folk仓库

作者: dc的梦呓 | 来源:发表于2020-07-07 21:25 被阅读0次

    如下情形:在github上fork的一个仓库remote-rep到自己的仓库下remote-rep1,clone remote-rep1到本地目录下进行修改,修改后push到remote-rep1。若原始仓库remote-rep更新了,想要把这些更新也更新到自己的仓库中remote-rep1。可进行如下操作:

    # 添加远程仓库,可称为 upstream
    git remote add upstream https://github.com/[source]/remote_rep.git
    
    # 获取远程仓库的更新
    #Fetch all the branches of that remote into remote-tracking branches,
    # such as upstream/master:
    git fetch upstream
    
    # Make sure that you're on your master branch:
    git checkout master
    
    # Rewrite your master branch so that any commits of yours that
    # aren't already in upstream/master are replayed on top of that
    # other branch:
    git rebase upstream/master
    

    更新完后,再将本地仓库的修改后推送至remote-rep1:

    #only need to use the -f the first time after you've rebased
    git push -f origin master
    

    参考资料
    https://stackoverflow.com/questions/7244321/how-do-i-update-a-github-forked-repository

    相关文章

      网友评论

          本文标题:git 更新远程仓库至folk仓库

          本文链接:https://www.haomeiwen.com/subject/fmcaqktx.html