Sync Branch and staying up to date with a project using GitHub for Windows

假如想象 提交于 2019-12-03 17:05:01

问题


What do I need to do in the GitHub for Windows app to stay up to date with changes made to a project or repository hosted on GitHub?

I will most likely not be editing, but do want to stay aware of and incorporate the changes that are made to the project.

When I clone in desktop, using the GitHub for Windows GUI, one of the options I have is "Sync Branch", which is defined as "sharing your local commits on the server and pulling down changes from others". With whom am I sharing my local commits? Is it the origin source? And, whose changes am I "pulling down"?

It seems like the "sync branch" option in the GUI would do both (whether I want to or not).


回答1:


You can fork the repo (even if you don't intend to contribute back), if only to keep a clear link with the original upstream repo.

From there, you can:

  • clone your fork locally
  • add a remote referring to the upstream original repo

    git remote add upstream https://github.com/User/repo
    
  • set the upstream branch to the remote 'upstream'.
    That way, a simple git pull will always pull from the original repo (the upstream one)

    git checkout master
    git branch -u upstream/master
    
  • set push.default to matching.
    That way, a git push origin will push all your local branches (updated from upstream) to your fork.

    git config push.default matching
    

The idea behind those settings is: pulling from upstream, but pushing to origin, meaning keep track of the new changes: you record in your fork the last SHA1 you pulled from upstream.

That way, you can from any workstation:

  • pull from origin (to update your local clone to the last SHA1 you memorized in your fork),
  • and pull from upstream in order to check/see any new commits from said original repo.


来源:https://stackoverflow.com/questions/21845740/sync-branch-and-staying-up-to-date-with-a-project-using-github-for-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!