我分叉了一个项目,进行了更改,并创建了一个被接受的拉取请求。新的提交后来被添加到存储库中。我怎样才能把这些承诺交给我?


当前回答

克隆分叉存储库后,转到克隆所在的目录路径和GitBash终端中的几行。

$ cd project-name

$ git remote add upstream https://github.com/user-name/project-name.git
 # Adding the upstream -> the main repo with which you wanna sync

$ git remote -v # you will see the upstream here 

$ git checkout master # see if you are already on master branch

$ git fetch upstream

你很好去那里。主存储库中所有更新的更改都将被推送到您的fork存储库中。

“fetch”命令对于保持项目中的最新状态是必不可少的:只有在执行“gitfetch”时,您才会被告知同事对远程服务器所做的更改。

您仍然可以访问此处进行进一步查询

其他回答

使用这些命令(在幸运的情况下)

git remote -v
git pull
git fetch upstream
git checkout master
git merge upstream/master --no-ff
git add .
git commit -m"Sync with upstream repository."
git push -v

前言:您的分叉是“源”,您分叉的存储库是“上游”。

假设您已经使用如下命令将分叉克隆到计算机:

git clone git@github.com:your_name/project_name.git
cd project_name

如果已给出,则需要按以下顺序继续:

将“上游”添加到克隆的存储库(“源”):git远程添加上游git@github.com:original_author/project_name.git从“上游”获取提交(和分支):git获取上游切换到分叉的“master”分支(“origin”):切换到主分支停止“主”分支的更改:暂存将“上游”的“主”分支中的更改合并到“源”的“母”分支中:git合并上游/主解决合并冲突(如果有)并提交合并gitcommit-am“从上游合并”将更改推到叉上数字推送找回你藏起来的零钱(如果有的话)吉特藏弹你完了!祝贺

GitHub还提供了有关此主题的说明:同步分叉

尝试此操作,单击“获取上游”以从上游主机同步分叉的回购。

截至本答复之日,GitHub在web界面中还没有(或者我应该说不再有?)这一功能。然而,你可以问support@github.com加上你的一票。

与此同时,GitHub用户bardiharborow创建了一个工具来实现这一点:https://upriver.github.io/

来源在这里:https://github.com/upriver/upriver.github.io

假设你的叉子是https://github.com/me/foobar原始存储库是https://github.com/someone/foobar

参观https://github.com/me/foobar/compare/master...someone:master如果您看到绿色文本“能够合并”,请按Create pull request在下一页上,滚动到页面底部,然后单击合并请求和确认合并。

使用以下代码段生成链接以同步分叉存储库:

新Vue({el:“#app”,数据:{yourFork:'https://github.com/me/foobar',原始回购:'https://github.com/someone/foobar'},计算:{syncLink:函数(){const yourFork=新URL(this.yourFork).pathname.split('/')const originalRepo=新URL(this.originalRepo).pathname.split('/')如果(yourFork[1]&&yourFork[2]&&originalRepo[1]){返回`https://github.com/${yourFork[1]}/${yourFork[2]}/compare/master${originalRepo[1]}:主`}return“数据不足”}}})<script src=“https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js“></script><div id=“app”>您的分叉URL:<inputsize=50v-model=“yourFork”/><br/>原始存储库URL:<input v-model=“originalRepo”size=50/><br/>用于同步分叉的链接:<a:href=“syncLink”>{syncLink}</a></div>