Sunday 15 April 2012

git - Check status of local Python relative to remote with GitPython -


How can I use to determine:

  • My local branch
  • My local branch is behind the remote (I can safely pull)
  • Is my local branch separated from the remote?

    To see if local and remote are similar, I am doing this:

      def local_and_remote_are_at_same_commit (repo, remote): local_commit = repo Commit () remote_commit = remote.fetch () [0]. Return Commit Local_IIT. Hex: == remote_committ.  

    see

    example

    commits_behind = repo.iter_commits ('master..origin / master')

    and

    commits_ahead = repo.iter_commits ('original / master ..masters')

    Then you can use something like this to go from the iterator to the count:

    count = amount (1 C for commits_ahead)

    Th was finally checked with GitPython 1.0.2.

No comments:

Post a Comment