All Questions
Tagged with gitpython python-3.x
58 questions
0
votes
0
answers
97
views
GitPython unable to execute command in existing repository
I am trying to run a script with GitPython, but it seems to only fail when I run from inside the Jenkins automation environment. The error that it gives isn't very helpful (and I haven't been able to ...
1
vote
1
answer
159
views
Add safe directory with gitpython
How do I run this git command with gitpython(v2.1.*), please ?
git config --global --add safe.directory "some_dir"
Couldn't find in doc.
I tried this:
repo = git.Repo.init(some_dir)
config =...
0
votes
0
answers
109
views
Trouble pushing to Git remote using GitPython: "remote unpack failed" and "RPC failed; HTTP 500"
I'm encountering issues when trying to push changes to a Git remote repository using GitPython. I'm receiving two different errors intermittently, and I'm unsure how to resolve them.
Error 1
error: ...
0
votes
1
answer
195
views
How to call rev_list with GitPython
This program fails
import git
repo = git.repo.Repo('..')
res = repo.git.rev_list('--since="2024-01-01" master').split('\n')
with the following error
git.exc.GitCommandError: Cmd('git') ...
0
votes
1
answer
327
views
GitPython: get rename files as deleted and added
I need to get git diff files since specific commit using GitPython. As I understood I get renamed files using 'R' type . Is it possible to get the rename_from in the deleted lists and the rename_to in ...
0
votes
1
answer
637
views
Mocking GitPython Repo Calls
I've got a class with a function that adds unstaged changes in a git repo and commits them
def commit_local_changes(self, repo_path):
repo = Repo(repo_path)
changed_files = repo....
0
votes
1
answer
242
views
How to execute --track, using GitPython(as a python script). "git checkout -B <branchname> --track origin/<TeamBranch>"
I can execute "git checkout -B --track origin/TeamBranch" through terminal. but I have the requirement to implement the above command through my script using Gitpython.
can someone help me ...
0
votes
0
answers
1k
views
module 'git' has no attribute 'Repo' - when running as non-root user.. works as root user
As above, I wrote a gitlab pre-receive hook that runs as a 'git' user on our gitlab server. When testing it, I get the above error. However when I SSH into the server and manually run the script as ...
0
votes
0
answers
1k
views
How to get time of last commit date for Git repository files via Python?
I'm trying to get the latest commit date for each file in a specific folder in a repo.
My code:
import git
import os
dir_path = os.path.dirname(os.path.realpath(__file__))
repo = git.Repo(dir_path)
...
1
vote
1
answer
364
views
Download files temporarily from a git repo - leaves orphaned git process
I want to get the contents of a git repo into a temporary directory so I can copy the files I need elsewhere and then delete the rest. I've done this:
import git
import contextlib
import tempfile
@...
1
vote
0
answers
311
views
Get file commit time in GitPython
How we can get the commit time of file (blob) via Gitpython while traversing the tree?
I need to get commit time of each FILE (not directory) in the full repo/tree. Something as we get via command git ...
6
votes
2
answers
3k
views
How to get master/main branch from gitpython
How one can know about the master/main branch at git remote with git-python.
I am aware that we can iterate over the heads of the repository and then check the results. Something like
repo = git.Repo('...
0
votes
0
answers
297
views
How to get info after push to GitLab with gitpython
I'm using the gitpython library to interact with GitLab. It works fine (push and create MR) except I can't find how to obtain a message (remote:) from GitLab after the push.
$ git push
Enumerating ...
0
votes
0
answers
153
views
Returning all repos under a given root path using GitPython
If I provide a root path such as ("C:/ProgramFiles") to the function,
the code should give a list, where each element is the
(local path of this repo found under the root path, remote URL, ...
1
vote
2
answers
2k
views
How to use python to check whether there are unstaged/uncommitted change or unpushed commit in a git repo
How to use python to check whether there are unstaged/uncommitted change or unpushed commit in a git repo?
I only know the command line
git status would tell
unstaged change
uncommitted stage
also ...