Skip to content

Comparing the difference between 2 RemoteReferences #1178

Answered by Byron
dclong asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for posting - I can reproduce the issue now.

Here is a 'fixed' version of the script above, note the lack of .diff when printing.

#!/usr/bin/env python3
import tempfile
import subprocess as sp
import git
from git import Repo

url = "https://github.com/dclong/docker-ubuntu_b.git"
dir_local = tempfile.mkdtemp()
repo = git.Repo.clone_from(url, dir_local, branch="main")
ref_main = next(ref for ref in repo.refs if ref.name == "origin/main")
ref_debian = next(ref for ref in repo.refs if ref.name == "origin/debian")
diffs = ref_main.commit.diff(ref_debian.commit)
# check whether there are any diff 
print("origin/main vs origin/debian using GitPython:") 
print(diffs) # ⬅ also shows that th…

Replies: 9 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Byron
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1113 on February 26, 2021 11:18.