Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merging branches with Pycharm using Github repo

What is the correct way to merge two branches of a Github project with Pycharm?

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.


Now, I want to merge the changes from the dev branch to the master branch.

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.

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: Merge local dev to local master, delete local dev, merge local master with remote master
  • Github: Create PR, merge branches, delete dev
  • Pycharm: Delete remote 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...

Sadly, there's also no Pycharm manual for merging branches with Github (for normal git there is). Any idea?

like image 329
0vbb Avatar asked Aug 18 '26 14:08

0vbb


1 Answers

The solution is to manually push your branch merge as it seems that pycharm doesn't do this, but it thinks it has.

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
like image 101
The Puternerd Avatar answered Aug 22 '26 04:08

The Puternerd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!