两种更新GitHub仓库的方法

两种更新GitHub仓库的方法

一、通过浏览器直接更新

  1. 打开你的GitHub仓库 me/projectName.
    点击 Compare :

    click compare

  2. 如果你的仓库已是最新的,你就会看到:

    nothing to update
    如果你的仓库需要更新,你会看到:

    need to update

    点击 switching the base, 你会看到你上次更新后所有提交到 someone/projectName 的修改.

  3. 点击 Creat pull request:

    creat pull request

    填写标题和描述,然后点击 Creat pull request.

  4. 滚到页面底部然后点击 Merge pull request,然后 Confirm merge.这时,你的仓库就已经是最新的了.

    merge pull

  5. stackoverflow上的参考回答

二、通过本地仓库进行同步

  1. 把你GitHub仓库克隆到本地目录下:
    git clone https://github.com/your_github/repositoryName.git

  2. 尝试 git remote -v, 如果你只能看到你自己的 origin(fetch/push),那就需要你手动添加另一个远程仓库然后命名为 upstream:
    git remote add upstream https://github.com/someone/repositoryName.git

  3. 合并主仓库:
    git fetch upstream
    git merge upstream\master

  4. 现在, 你的本地仓库已经是最新的了.但GitHub仓库还是老的.所以你需要推送更新到你的GitHub仓库.
    git push origin master

  5. 参考文章

posted @ 2019-11-15 21:57  木鱼啊  阅读(3259)  评论(0)    收藏  举报