Skip to content

git diff <local branch> <remote>/<remote branch> possible using gitpython ? #989

@hcheruku

Description

@hcheruku

Hi team,

I looked into remote and diff part of the documentation & API but couldn't find a way to achieve git diff between local and remote repo.

Here's what I am trying to achieve:
check if local repo matches remote repo, and ONLY if remote repo has any/some updates then pull and update the local repo.

from git import Repo
Repo(local_repo_path).remote().pull(branch)

The above code works sucessfully to pull the changes, but I only want to pull only if there's any update in the remote repo. Not sure how to achieve this.

Basically I want git diff <local branch> <remote>/<remote branch> and want to compare before I pull. Do I have to do Repo(repo_path).remotes.origin.fetch() as well ?

Thank you.
Have a great day!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions