Git forking and pull-request workflow

喜欢而已 提交于 2019-12-10 08:56:57

问题


I have a repo of a react project. I'd like to take that repo as the "base" of a few other projects and use it as a starting point. I'd also like to keep all of the other repos which stem from it up-to-date based on what the "base" has going on.

I am using Bitbucket for remote repo hosting and Tower locally as a nice GUI.

Is the correct way to do this is fork the "base" in Bitbucket, and then clone it locally? Will the local repo be aware of updates to the "base" repo in any way? How would I know if a significant commit has been made to the "base" repo which would benefit any of the forked repos?

Alternately, if I make a change to the forked repo that would benefit all of the other repos, can I do a pull-request so the "base" repo knows that it should pull in the updates?

Please excuse any ignorance, I've not used forking or pull-requests at all at this time and am trying to get my head around it :)


回答1:


Will the local repo be aware of updates to the "base" repo in any way?

No: you will need to add a remote, named (usually) upstream, referencing the original repo

cd /path/to/local/clone/of/fork
git remote add upstream /url/original/repo

git checkout master

# detailed step:
git fetch upstream
git merge upstream/master

# or (shorter)
git pull upstream master

Alternately, if I make a change to the forked repo that would benefit all of the other repos, can I do a pull-request so the "base" repo knows that it should pull in the updates?

Yes, that would be a classic pull request.



来源:https://stackoverflow.com/questions/51562124/git-forking-and-pull-request-workflow

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