When a local repository is a clone of a remote github repository, we should be able to facility updates in both directions, namely:
pushing local changes to remote
pulling remote changes to local
We can granularise the process by checking which modules are out-of-sync with remote by running
git diff --name-only origin/main -- .
or replacing . with /path/to/folder if we only want to check specific projects. This will list files with changes.
We can check if a repo is out-of-date with the remote by using GitPython as follows:
import git
repo = git.Repo('.') # current folder
repo.remotes.origin.fetch() # can just fetch branch here, e.g. fetch('main')
commits_match = repo.heads['main'].commit == repo.remotes.origin.refs['main'].commit
Node solutions like isomorphic-git offer platform independent implementations of git, but unfortunately do not perform well in practise due to e.g. lack of ssh repo support.
When a local repository is a clone of a remote github repository, we should be able to facility updates in both directions, namely:
We can granularise the process by checking which modules are out-of-sync with remote by running
or replacing
.
with/path/to/folder
if we only want to check specific projects. This will list files with changes.We can check if a repo is out-of-date with the remote by using GitPython as follows:
Node solutions like
isomorphic-git
offer platform independent implementations of git, but unfortunately do not perform well in practise due to e.g. lack of ssh repo support.