0

I am trying to merge two branches using gitpython.To test it out I have a kept a single file main.py with different code in two branches master and release.Finally I am merging the release branch onto master.After the merge operation the code in master branch is just getting replaced with the code in release branch.

main.py(Master)

import os

main.py(Release)

import git

Merge.py(Code-snippet)

repo = git.Repo.clone_from(HTTPS_REMOTE_URL, DEST_NAME)
repo.git.checkout('release')
repo.git.checkout('master')
repo.git.merge('release')

main.py(Master - Expected)

import os
import git

main.py(Master - Actual)

import git
Shashank Singh
  • 163
  • 4
  • 11
  • 1
    What's in the *merge base* version of that file? Remember, every merged file has *three* inputs; two branch tips, and one merge base. The merge result depends on the comparison of the merge-base vs the `--ours` commit, and then the comparison of the merge-base vs the `--theirs` commit. Without the merge-base, you're comparing `--ours` vs `--theirs`, and that tells you precisely nothing useful. – torek May 10 '19 at 12:47

1 Answers1

0

There was an another issue due to which the merge was not working.The above code works fine to merge one branch onto another.

Shashank Singh
  • 163
  • 4
  • 11