我分叉了一个项目,进行了更改,并创建了一个被接受的拉取请求。新的提交后来被添加到存储库中。我怎样才能把这些承诺交给我?
当前回答
我用这一行更新我的分叉回购:
git pull https://github.com/forkuser/forkedrepo.git branch
如果您不想在项目中添加另一个远程端点,请使用此选项,如其他解决方案所示。
其他回答
Android Studio现在已经学会了使用GitHub fork存储库(您甚至不必通过控制台命令添加“上游”远程存储库)。
打开菜单VCS→ Git公司
并注意最后两个弹出菜单项:
重新使用我的GitHub分叉创建拉取请求
试试看。我使用第一个来同步本地存储库。无论如何,在您单击“Rebase my GitHub fork”后,可以在Android Studio中访问父远程存储库(“上游”)的分支,您将能够轻松地使用它们进行操作。
(我使用带有“Git集成”和“GitHub”插件的Android Studio 3.0。)
如何在本地计算机上更新分叉回购?
首先,检查遥控器/主机
git remote -v
你应该有起点和上游。例如:
origin https://github.com/your___name/kredis.git (fetch)
origin https://github.com/your___name/kredis.git (push)
upstream https://github.com/rails/kredis.git (fetch)
upstream https://github.com/rails/kredis.git (push)
之后转到main:
git checkout main
并从上游合并到干管:
git merge upstream/main
尝试此操作,单击“获取上游”以从上游主机同步分叉的回购。
在分叉存储库的本地克隆中,可以将原始GitHub存储库添加为“远程”。(“Remotes”就像是存储库URL的昵称,例如,origin就是其中之一。)然后,您可以从上游存储库中获取所有分支,并重新设置工作基础,继续使用上游版本。就命令而言,可能如下所示:
# Add the remote, call it "upstream":
git remote add upstream https://github.com/whoever/whatever.git
# Fetch all the branches of that remote into remote-tracking branches
git fetch upstream
# Make sure that you're on your master branch:
git checkout master
# Rewrite your master branch so that any commits of yours that
# aren't already in upstream/master are replayed on top of that
# other branch:
git rebase upstream/master
如果您不想重写主分支的历史记录(例如,因为其他人可能已经克隆了它),那么应该用gitmergeupstream/master替换最后一个命令。然而,为了做出尽可能干净的进一步拉取请求,可能最好重新设置基址。
如果您已经将分支重新基于upstream/master,则可能需要强制推送,以便将其推送到GitHub上自己的分叉存储库。你可以这样做:
git push -f origin master
您只需要在重新启动后第一次使用-f即可。
从github页面删除远程设备
然后应用这些命令:
1) git branch -D dev
2) git fetch upstream
3) git checkout master
4) git fetch upstream && git fetch upstream --prune && git rebase upstream/master && git push -f origin master
5) git checkout -b dev
6) git push origin dev
7) git fetch upstream && git fetch upstream --prune && git rebase upstream/dev && 8) git push -f origin dev
要查看配置,请使用以下命令:
git remote -v
推荐文章
- 为什么我需要显式地推一个新分支?
- 如何撤消最后的git添加?
- Rubymine:如何让Git忽略Rubymine创建的.idea文件
- Gitignore二进制文件,没有扩展名
- Git隐藏错误:Git隐藏弹出并最终与合并冲突
- 了解Git和GitHub的基础知识
- 没有。Git目录的Git克隆
- 在GitHub上有一个公共回购的私人分支?
- Git与Mercurial仓库的互操作性
- 忽略git中修改(但未提交)的文件?
- 只用GitHub动作在特定分支上运行作业
- “git restore”命令是什么?“git restore”和“git reset”之间有什么区别?
- Git合并与强制覆盖
- Git拉另一个分支
- 是否有一个链接到GitHub下载文件的最新版本的存储库?