github sync from fork

℡╲_俬逩灬. 提交于 2019-12-08 05:58:00

问题


I am pretty new to github.

I made a fork from a third party, then I modified several files in this fork and committed to my fork. Based on my fork, I made a branch.

I noted there are some update in upstream (the third party source which I made the fork), so I sync my fork. Now how do I push the changes from my fork to my branch ?

Another situation is after I made some changes in my branch, how do I push them back to my fork?


回答1:


You need to do a:

git request-pull original_repo <repo_url> repo_with_changes

This is will pull the new code into the original_repo

Here is more information on it: https://git-scm.com/docs/git-request-pull




回答2:


Based on my fork, I made a branch. I noted there are some update in upstream (the third party source which I made the fork), so I sync my fork. Now how do I push the changes from my fork to my branch ?

Actually, if you have added a remote referring to the original repo, what you do is:

 git remote add upstream /url/original/repo
 git fetch upstream
 git checkout your-pr-branch
 git rebase upstream/master
 git push --force

This assume your-pr-branch was done from the upstream repo master branch.
You can also pull upstream/master into master and push master to your fork if you want to sync your fork.



来源:https://stackoverflow.com/questions/42570025/github-sync-from-fork

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