Git Push后GitHub未显示‘Compare & pull request’按钮问题排查
关于GitHub Pull Request按钮不显示的问题
我正在学习GitHub版本控制和Git命令,重点理解push和pull request概念。按照教程操作后,期望在GitHub看到‘Compare & pull request’按钮,但操作无报错却没看到该按钮,请问我遗漏了哪一步?
操作步骤
- 先fork了仓库kedark3/demo
- 执行本地操作:
- 克隆仓库:
git clone https://github.com/rejkid-tester/Demo.git到本地文件夹 - 创建分支:
git branch new_branch - 切换分支:
git switch new_branch - 用notepad.exe修改仓库中"test"文件内容
- 克隆仓库:
- 提交并推送变更:
a)git add .
b)git commit -m "Test"
c)git push origin new_branch
push命令输出
PS C:\workspace\GITTest\Demo> git push origin new_branch Enumerating objects: 5, done. Counting objects: 100% (5/5), done. Delta compression using up to 8 threads Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 334 bytes | 334.00 KiB/s, done. Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 remote: Resolving deltas: 100% (1/1), completed with 1 local object. remote: remote: Create a pull request for 'new_branch' on GitHub by visiting: remote: https://github.com/rejkid-tester/Demo/pull/new/new_branch remote: To https://github.com/rejkid-tester/Demo.git * [new branch] new_branch -> new_branch
git config信息
PS C:\workspace\GITTest\Demo> git config --list diff.astextplain.textconv=astextplain filter.lfs.clean=git-lfs clean -- %f filter.lfs.smudge=git-lfs smudge -- %f filter.lfs.process=git-lfs filter-process filter.lfs.required=true http.sslbackend=openssl http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt core.autocrlf=true core.fscache=true core.symlinks=false core.editor="C:\Program Files (x86)\Notepad++\notepad++.exe" -multiInst -notabbar -nosession -noPlugin pull.rebase=false credential.helper=manager credential.https://dev.azure.com.usehttppath=true init.defaultbranch=master user.email=rejkid@gmail.com user.name=rejkid-tester core.repositoryformatversion=0 core.filemode=false core.bare=false core.logallrefupdates=true core.symlinks=false core.ignorecase=true remote.origin.url=https://github.com/rejkid-tester/Demo.git remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* branch.master.remote=origin branch.master.merge=refs/heads/master remote.upstream.url=https://github.com/kedark3/demo remote.upstream.fetch=+refs/heads/*:refs/remotes/upstream/*
问题解答
你已经把分支推送到了自己的fork仓库(rejkid-tester/Demo),但GitHub默认只会提示向你自己仓库的master分支创建PR。而你需要的是向原仓库(kedark3/demo)提交PR,所以需要手动切换目标仓库:
- 打开你自己的fork仓库页面,找到刚推送的
new_branch分支 - 如果没直接看到"Compare & pull request"按钮,就点击分支旁的"Pull request"按钮进入PR创建页面
- 在页面顶部,将base repository从你的仓库切换为原仓库
kedark3/demo,base分支选择对应目标分支(比如master) - 确认head repository是你的fork仓库、分支是
new_branch,填写PR信息后提交即可
另外,push输出里的链接打开后,也可以在PR创建页面手动切换目标仓库完成操作。
内容的提问来源于stack exchange,提问作者janci
相关产品推荐
相关产品推荐

