使用Github仓库将分支与Pycharm合并 [英] Merging branches with Pycharm using Github repo
问题描述
假设Github项目中有一个名为 master
的分支,我用Pycharm克隆了仓库.之后,我使用Pycharm创建一个新的分支 dev
.然后,新分支将正确显示在Github上,并且对该分支进行了一些提交.
Suppose there is a branch in a Github project called master
and I clone the repo with Pycharm. After that, I create a new branch dev
by using Pycharm. The new branch is then shown correctly on Github and some commits are made to the branch.
现在,我想将更改从 dev
分支合并到 master
分支.
Now, I want to merge the changes from the dev
branch to the master
branch.
对于普通的git(不是Github)项目,我将签出到Pycharm中的本地 master
,单击本地分支中的 dev
,然后选择 合并 上下文菜单.结果, dev
将被合并到 master
中,以便可以安全地删除它.尽管如此,即使我合并了 local master
和 remote master
分支,Github上未显示任何更改,并且两个分支仍然存在.
For ordinary git (not Github) projects, I would checkout to the local master
in Pycharm, click on dev
in the local branch and select the merge context menu. As a result, dev
would be merged to master
such that it can be safely deleted.Though, even after I merge the local master
with the remote master
branch, no changes are shown on Github and both branches still exist.
我还尝试关闭Pycharm,在Github上执行拉取请求,合并那里的分支并重新启动Pycharm.不幸的是,Pycharm甚至不认识到 remote dev
分支已被删除.
I also tried to close Pycharm, do a pull request on Github, merge the branches there and restart Pycharm. Unfortunately, Pycharm doesn't even recognize that the remote dev
branch has been deleted.
我的次要解决方案如下:
My subpar solution has been as follows:
- Pycharm:将 local
dev
合并到 localmaster
,删除 localdev
,合并 localmaster
和 remotemaster
- Github:创建PR,合并分支,删除
dev
- Pycharm:删除远程
dev
- Pycharm: Merge local
dev
to localmaster
, delete localdev
, merge localmaster
with remotemaster
- Github: Create PR, merge branches, delete
dev
- Pycharm: Delete remote
dev
现在,如果我以Pycharm中的远程 master
为基础,则会得到正确的合并分支.不过遗憾的是,使用 compare 上下文菜单,Pycharm仍然显示与相比,远程 master
本地 master
没有来自 dev
的提交.尽管来自远程 master
的重新存储包含来自 dev
...
Now, if I rebase onto the remote master
in Pycharm, I get the correct merged branch. Unfortunately though, using the compare context menu, Pycharm still shows that the remote master
compared to the local master
doesn't have the commits from dev
. Although a rebase from the remote master
contains all the commits from dev
...
遗憾的是,也没有用于将分支与Git hub 合并的Pycharm手册(对于普通的git而言).有什么主意吗?
Sadly, there's also no Pycharm manual for merging branches with Github (for normal git there is). Any idea?
推荐答案
解决方案是手动推送分支合并,因为pycharm似乎没有这样做,但它认为有.
The solution is to manually push your branch merge as it seems that pycharm doesn't do this, but it thinks it has.
我注意到了相同的问题,并且似乎合并不是从本地副本中推送的.在命令外壳中,我签出了项目的master分支,它告诉我我领先于在线存储库,因此要解决此问题,我发出了 git push
命令,然后当我检查github时,已上传.
I've noticed the same issue and it seems that the merge is not pushed from the local copy. In a command shell I checkout the master branch of my project and it tells me that I am ahead of online repository, so to resolve this I issue the git push
command and then when I check github it has been uploaded.
(tf36) E:\git\alpha-zero-theputernerd>git checkout master
Already on 'master'
A src/alpha_zero/env/env_inherit_from.py
Your branch is ahead of 'origin/master' by 3 commits.
(use "git push" to publish your local commits)
(tf36) E:\git\alpha-zero-theputernerd>git push
Total 0 (delta 0), reused 0 (delta 0)
To https://github.com/theputernerd/alpha-zero-theputernerd.git
bb60325..37c3c9d master -> master
这篇关于使用Github仓库将分支与Pycharm合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!