Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
21 views

How to check for new commits in remote in a submodule without merging them [duplicate]

I want to check if a submodule has new commits. I want to use gitpython. Can i use git submodule status? I use: git submodule update -N and other git commands. The main task is to see if there are new ...
Aleksandr Safronov's user avatar
0 votes
1 answer
63 views

Azure devops throwing stderr: 'fatal: You are not currently on a branch.' when trying to push the code to checked out branch using GitPython library

I am trying to check out a git branch,generate files using python code and then push the changes to the branch using GitPython library Below is the code used repo = git.Repo(...
Sachin Shetty's user avatar
0 votes
1 answer
70 views

How can I get head of branch with illegal characters in it

I know you can get the head of a branch directly using it's name (e.g. repo.heads.main). Can you get the head of a branch that has illegal variable characters (e.g. feature-generate-events) directly ...
Stephen Rasku's user avatar
0 votes
0 answers
56 views

GitPython get list of all commits from HEAD to Previous HEAD

I am using GitPython module to get the list of all commits from HEAD to Previous HEAD Current HEAD --> Changes I made recently Previous HEAD --> When I cloned the repo So far, I tried the ...
Sathish Kumar's user avatar
0 votes
0 answers
63 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: ...
Ame Suzuki's user avatar
0 votes
0 answers
72 views

Get all the commits message of a file using GitPython

I have the following piece of code to get the list of commit summaries of a specific file: from git import Repo repo_working_dir = '<valid directory of the repo>' repo = Repo(repo_working_dir) ...
Rajesh's user avatar
  • 1
0 votes
0 answers
38 views

gitpython- tree.traverse() does not ignore items in .gitignore

I'm trying to traverse the list of ALL items managed by git in a repo that I have checked out in a local directory. The basic code I have is this: git_repo = git.Repo( '/path/to/some/directory' ) ...
user3696153's user avatar
0 votes
0 answers
203 views

Diffrence PYGIT2 versus PYGIT?

So I see there is a pip install gitpython and pygit2 - but cannot seem to determine what is the difference between the two. pros/cons - (A) does this, (B) does that - instead All I am trying to do is ...
user3696153's user avatar
0 votes
1 answer
414 views

Git diff against master branch using GitPython

I must be dense, but I haven't been able to find a solution yet. I am trying to get a list of all of the members (in all commits or not committed yet) that have changed on a branch in my Python ...
Mark Hammack's user avatar
0 votes
0 answers
124 views

Clone ssh git repositories using python 3

I have this Python Script that clones a list of length n of repositories using ssh. import pandas as pd import time import git import sys import os counter = 0 #excel reader resources = pd....
CamiCode's user avatar
0 votes
0 answers
48 views

Last git changes on a given file

Using the gitpython library, I'm trying access the date of the last changes on a given file. So far I only found out how to: import git # get a handle on a repo object for the current directory repo=...
Antoine Gallix's user avatar
0 votes
1 answer
100 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') ...
Dmitry's user avatar
  • 1,205
0 votes
0 answers
39 views

GitPython: How to check whether a submodule is on needed commit?

Want to check whether the submodule is already on the correct commit after the repo branch is changed. For example: Suppose for a repository named sample there are two submodules itemA and itemB. ...
Shobhit Shrivastava's user avatar
1 vote
0 answers
81 views

Continuously print output of GitPython git.execute()

I'm running a command with GitPython git.execute(). Currently, I'm writing the return value to a window. Because the command takes some time, the window will not show any progress for a few seconds ...
Christian's user avatar
  • 169
0 votes
1 answer
108 views

Write to PySimpleGUI.Multiline from logging.Handler throws exception

I have a PySimpleGUI with a button and a multiline. When I click on the button, a method is called and running for a couple of seconds (calls i.a. GitPython methods). The method shall write its output ...
Christian's user avatar
  • 169
0 votes
0 answers
134 views

Pushing to BitBucket with an SSH key using gitpython

I'm trying to push some files to BitBucket using gitpython and an SSH key. It works fine when I do it through Git Bash, but when I try it using gitpython I keep getting this error: Cmd('git') failed ...
Josh's user avatar
  • 37
0 votes
1 answer
734 views

Get list of directories and files in git repo using Python

I want to fetch all files and directories present in a git repo using Python and then parse through each directory to get details of files present under them. Below is the piece of code I have been ...
Shivani's user avatar
0 votes
1 answer
56 views

gitpython commit not writing to disk

I am trying to write a basic script that is pulling replicating the contents of one directory into another one, but making some modifications along the way. The items written in the new directory are ...
Panduar's user avatar
  • 31
0 votes
0 answers
76 views

How do I fix syntax errors related to type hints when using an external library like GitPython?

When trying to run a Python script I got the following errors: Traceback (most recent call last): File "C:\Users\{User}\AppData\Local\Programs\Python\Python35-32\lib\site-packages\git\__init__....
eRod's user avatar
  • 11
1 vote
1 answer
174 views

Python clone a private GitHub repo via SSH authentication without access to ssh binaries (under Azure Functions)

Our team needed to clone a private GitHub repo within an Azure Function, where you can only run Python code - but there is no access to the shell or pre-installed Git or SSH binaries. At the same ...
Dmitry Alergant's user avatar
1 vote
0 answers
465 views

How to clone Azure DevOps git repository with OAuth token from service principal?

I am trying to clone an Azure DevOps git repository using an Azure app registration/service principal. I was successful in bash with the help of this answer. Sadly, adapting it to GitPython results in ...
Felix Thein's user avatar
0 votes
1 answer
245 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 ...
Leah's user avatar
  • 29
3 votes
2 answers
3k views

GitPython: error: Module "git" does not explicitly export attribute "Repo" [attr-defined]

I am using Python 3.10.4, GitPython version 3.1.31, mypy version 1.4.1: $ pip show GitPython Name: GitPython Version: 3.1.31 Location: /home/hakon/.pyenv/versions/3.10.4/lib/python3.10/site-packages ...
Håkon Hægland's user avatar
0 votes
1 answer
125 views

Retrieving SHA from gitpython when User is not Owner of Cloned Repo on Windows 11?

I am using the gitpython library to obtain the SHA of Python code during execution on a Windows 11 Enterprise PC. It works fine when I do it as I cloned the repo. When another user tries to run the ...
Bobby's user avatar
  • 23
0 votes
1 answer
488 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....
wyt's user avatar
  • 115
2 votes
0 answers
336 views

How can I calculate exact total changed LOC of pull requests in a project which uses Azure DevOps (with GitPython)

I have a project which uses Azure DevOps as version control system. I want to get total changed line of code count for every pull request in the project. To do this, I send a request to Azure DevOps ...
Sergen's user avatar
  • 21
0 votes
1 answer
140 views

gitpython fetch get chinese named branch get encoding error

Python version 3.11.3 When I use gitpython, my codes like below os.environ["PYTHONIOENCODING"] = "utf-8" os.environ["PYTHONUFT8"] = "on" repo = Repo(repo_path) ...
dino he's user avatar
0 votes
0 answers
108 views

Problem with git.remote.RemoteProgress method from Gitpython

i try to show the progress using this code in pyQt5 Widget : import sys from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QProgressBar, QVBoxLayout from PyQt5.QtCore import QObject, ...
Ahbar Abdellah's user avatar
2 votes
0 answers
54 views

Git : Given MR id , how to find corresponding target branch?

I was going through git commands and I was not able to find a command that takes in MR id and gives somthing like merge request object from where I can get target branch. Is there any such git command ...
Ajinkya Dandvate's user avatar
0 votes
1 answer
95 views

Why gitpython results doesn't match to the github website?

I use the following python code to extract the diff (the hunks) between two commits. from git import Repo !git clone https://github.com/apache/commons-math.git repo = Repo("/content/commons-math&...
Sadegh Sh's user avatar
1 vote
0 answers
62 views

Removing a git submodule without a path

I somehow have a git submodule without a path, which I would like to remove. Looking into the submodules of my codebase, there is some weird config: [submodule "a/path"] path = a/path ...
Tom's user avatar
  • 93
1 vote
1 answer
396 views

How to fetch an orphaned commit?

tl;dr: I have a repository cloned but cannot see an orphaned commit locally. How can I get that commit if it did not come with the repo? Details: I am trying to get the contents of a specific file on ...
smgtkn's user avatar
  • 118
0 votes
1 answer
425 views

GitPython find most recent tag in the current branch only

I am using this code snippet with GitPython to capture the current branch, most recent commit, and most recent tag. This information will be inserted into a version string. repo = git.Repo(...
Steve's user avatar
  • 1,280
1 vote
0 answers
304 views

How do I set a progress bar when cloning a repository with GitPython?

I would like to set a progress bar when cloning a repository with GitPython, by using some library such as tqdm. For the moment I wrote the following code in the main.py: import git ...some code... ...
Admin's user avatar
  • 49
0 votes
1 answer
572 views

empty commit with Repo.commit()

I'm trying to do something like repo.git.commit('-m', 'test commit', author='[email protected]') but instead of the author, I want to pass the --allow-empty to send a dummy commit to the repo. but the ...
c0d3rbox's user avatar
0 votes
1 answer
198 views

Python PyTest running GitPython under Tox in Ubuntu Docker image: commit fails with Committer/Author identity unknown

Q+A (I'm posting this in case someone else goes down this niche rabbit hole - as it took me a while to figure this out). Scenario: You've decided to run a unit-test which 'plays' with creating a local ...
shaib's user avatar
  • 26
1 vote
1 answer
533 views

GitPython cloning and pushing in remote directory

I am writing a script that clones and pushes something to the repository on gitlab. The thing is I have to clone to a specific directory on the filesystem and push from the same directory the project ...
JBravo's user avatar
  • 93
2 votes
0 answers
64 views

How to get files change of a given branch?

I struggle to find how to get the list of files that have been modified on my current branch (and ONLY on my current branch, not on the other branches). For example, I have a branch my_branch based on ...
lucas_v67's user avatar
1 vote
1 answer
168 views

Have GitPython stage itself

I am new to GitPython and I am trying to have a python program stage itself to a new git repository (my-new-repo). My main.py is as follows: import git repo = git.Repo.init('my-new-repo') # List all ...
Hitesh Arora's user avatar
1 vote
2 answers
498 views

Parse git config file using git python

So if I have a git config file something like this. [color "branch"] current = yellow bold local = green bold remote = cyan bold I want to read the text between in quotes. I ...
Random Dude's user avatar
0 votes
1 answer
85 views

How to get Number of files touched, Number of lines added, Number of lines removed from for commit in repo.iter_commits(branch) using python git?

I would like to store the following info per commit like so, for commit in repo.iter_commits(branch): author_name=commit.author.name commit_id=commit commit_authored_date=datetime.datetime....
Gargee Suresh's user avatar
1 vote
1 answer
312 views

cannot do hard reset with gitpython

I am using the following code using gitpython: g = git.cmd.Git(r'C:\Users\alex\Files\Repo\Scripts') g.reset('--hard') g.pull() but I get the following error: GitCommandError: Cmd('git') failed due to:...
chulo's user avatar
  • 63
0 votes
1 answer
249 views

Unable to get complete git history of file with python

I am trying to get all the content from each revision - history of a file in my local repo i am using gitpython lib and here is the code: import git,json from pprint import pprint repo = git.Repo() ...
rick_sorkin's user avatar
1 vote
2 answers
527 views

Make copy of single file in a specific git repository commit

I need to get and make a copy of a single file in a specific commit. I'm using git show to accomplish this: >> git show 4c100bd6a48e3ae57a6d6fb698f336368605c0a2:test_file.txt >> ...
guidout's user avatar
  • 342
2 votes
2 answers
1k views

Automated git pull from local Gitlab repository using gitpython requires [email protected] password

We have a locally hosted Gitlab repository which I am trying to automate pushing and pulling with gitpython over ssh with the following script: LOCAL_REPO_PATH = "/path/to/repository" repo =...
Jake Mullins's user avatar
0 votes
1 answer
220 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 ...
Sai ram's user avatar
3 votes
0 answers
994 views

Python way of doing git remote add origin

Is there a way to this in Python? git remote add origin https://gitlab.com/xxxx/aaa/bbb/feature2.git git branch -M main git push -uf origin main Things I have tried: I tried to do from git import ...
Adam's user avatar
  • 1,265
0 votes
0 answers
889 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 ...
Shox2711's user avatar
  • 139
0 votes
0 answers
2k views

AttributeError: module 'git' has no attribute 'Repo' - working on local machine but not on remote server

I've read through other solutions on here for general module x has no attribute y to no avail. What's catching me here is that this works fine on my local machine. When I transfer it over to a remote ...
Shox2711's user avatar
  • 139
0 votes
0 answers
2k views

How do I pass username and access token automatically to Repo.clone_from() command using Gitpython?

I am trying to clone a GitLab repo in a python script using GitPython. I want it to be able to clone this private repo from GitLab without me having to manually input my username and auth token each ...
mandypea's user avatar

1
2 3 4 5
11