如何与远程 Git 存储库同步?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4313125/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to sync with a remote Git repository?
提问by George Profenza
I forked a project on github, made some changes, so far so good.
我在 github 上 fork 了一个项目,做了一些改变,到目前为止一切顺利。
In the meantime, the repository I forked from changed and I would like to get those changes into my repository. How do I do that ?
与此同时,我分叉的存储库发生了变化,我想将这些更改放入我的存储库中。我怎么做 ?
采纳答案by ?imon Tóth
Generally git pull
is enough, but I'm not sure what layout you have chosen (or has github chosen for you).
一般git pull
就足够了,但我不确定你选择了什么布局(或者 github 为你选择了什么)。
回答by Mark Hibberd
Assuming their updates are on master, and you are on the branch you want to merge the changes into.
假设他们的更新在 master 上,并且您在要将更改合并到的分支上。
git remote add origin https://github.com/<github-username>/<repo-name>.git
git pull origin master
Also note that you will then want to push the merge back to your copy of the repository:
另请注意,您随后需要将合并推送回您的存储库副本:
git push origin master
回答by Alex
You have to add the original repo as an upstream.
您必须将原始回购添加为上游。
It is all well described here: https://help.github.com/articles/fork-a-repo
这里有很好的描述:https: //help.github.com/articles/fork-a-repo
git remote add upstream https://github.com/octocat/Spoon-Knife.git
git fetch upstream
git merge upstream/master
git push origin master
回答by Abizern
You need to add the original repository (the one that you forked) as a remote.
您需要将原始存储库(您分叉的存储库)添加为远程存储库。
git remote add github (clone url for the orignal repository)
git remote add github(原始存储库的克隆 URL)
Then you need to bring in the changes to your local repository
然后您需要将更改引入本地存储库
git fetch github
git 获取 github
Now you will have all the branches of the original repository in your local one. For example, the master branch will be github/master
. With these branches you can do what you will. Merge them into your branches etc
现在,您将在本地存储库中拥有原始存储库的所有分支。例如,主分支将是github/master
. 有了这些分支,您就可以为所欲为。将它们合并到您的分支等中
回答by Guest
For Linux:
对于 Linux:
git add *
git commit -a --message "Initial Push All"
git push -u origin --all