Questions tagged [gitpython]

GitPython is a python library used to interact with Git repositories

GitPython is a python library used to interact with Git repositories, providing object model access.

495 questions
0
votes
1 answer

pip install gitpython fails with python 3.x requirement

When I try to install gitpython via pip normally under python 2.7, it fails telling me python 3.x is required. This particular script/process has worked until this morning. $ sudo pip install gitpython Looking in indexes: https://pypi.org/simple,…
LCB
  • 91
  • 1
  • 11
0
votes
1 answer

How to use variables of git submodule foreach in gitpython

Using gitpython, I would like to use repo.git.submodule('foreach', …) and get the variables available such as name, sm_path, displaypath, sha1 and toplevel as defined in the git documentation. I couldn't find any documentation on gitpython and my…
Denis Rouzaud
  • 2,412
  • 2
  • 26
  • 45
0
votes
1 answer

How to Checkout out a branch

I got gitpython working to clone a repo, now i need to checkout out branches inside that repo i've been looking at the documentation but cant seem to find it import git import os import shutil DIR_NAME = "temp" REMOTE_URL = "" if…
0
votes
1 answer

Gitpython merge replacing the code in master from the merged branch

I am trying to merge two branches using gitpython.To test it out I have a kept a single file main.py with different code in two branches master and release.Finally I am merging the release branch onto master.After the merge operation the code in…
Shashank Singh
  • 163
  • 4
  • 11
0
votes
1 answer

Checkout a remote branch without tracking it

I have forked a project in Gitlab to my own namespace. I want to create a new branch of that project that mirrors the original repo's master but I do not want to set a remote in my forked repo nor do I want to track that branch. Is there any way I…
0
votes
1 answer

How to get the directory git detail from repo in GitPython?

I would like to get the number of commit of a directory(called module) from a repo(project) in GitPython. > print("before",modulePath) > repo = Repo(modulePath) > print(len(list(repo.iter_commits()))) When I'm trying to print…
Ioan S.
  • 154
  • 3
  • 14
0
votes
1 answer

GitPython repo.git.checkout not checking out branch correctly

I am using following code to checkout or switch the branch within python code, repo.git.checkout('branch_name') But when the code later executes is still referring to 'master' branch code. I am using GitPython version 2.1.11.
0
votes
1 answer

How to query the log of a specific git repo branch using gitpython?

Goal: Perform the following git command within a python script using gitpython. cmdLine Version: git log -L :dataLoad:/home/ubuntu/projects/alpha-draw/py/enigma.py Script Version: repo.git.log(f'-L…
Kyle Swanson
  • 1,308
  • 1
  • 12
  • 20
0
votes
2 answers

Git python script to extract all the later commits from a given sha commit id

Am trying to use Python to extract the list of all commit messages from a branch after a specific start commit. i couldn't find any useful function from GITPython api or maybe i just missed it. Could anyone please guide me with it?
sbkhbk
  • 31
  • 2
  • 8
0
votes
1 answer

GitPython: Check submodule remote changes

I have a repo including two submodules. I want to detect the changes in submodules. For example, I have a repo called repo1 and there are two submodules in it called sub_repo1 and sub_repo2. I want to detect changes in these two submodules and…
Elegant Lin
  • 25
  • 2
  • 10
0
votes
0 answers

Connection and Execution GIT commands using Python

I am trying to connect and execute GIT commands using python such as pull, check status, add and commit new files etc. I am using python 3.7, PyCharm for IDE and GitPython 2.1.7 as a library. I have also used the following tutorial:…
DB-93
  • 13
  • 4
0
votes
2 answers

How to get list of commits that were not push to master GitPython

I am using GitPython, I am trying to somehow see if all my local commits where push to the remote server. I can see differences between my current local state and master doing this : import git t =…
Steven G
  • 16,244
  • 8
  • 53
  • 77
0
votes
0 answers

Can't create a remote branch using GitPython on Windows 10

This code is from tutorial and it works for Mac and Linux, but doesn't work for Windows 10. folder = os.path.abspath(folder) repo = git.Repo.init(folder) origin = repo.create_remote('origin', repository) origin.fetch() repo.create_head('master',…
Oduvan
  • 2,607
  • 3
  • 24
  • 24
0
votes
1 answer

how to create release in repository using python code

I created a tag in repository using git lib in python. this code works fine and creates a new tag: repo = Repo(repo_path) repo.create_tag('some tag..') now I'm trying to make this tag into a Release and yet found a solution. thanks
0
votes
0 answers

GitPython to pull a specific directory

To pull a specific directory in the remote using git I would do: > git fetch > git checkout / -- relative/path/to/file/or/dir How do I do the same using GitPython? I'm trying to figure it out but no cigar so far. …
Jamie Marshall
  • 1,885
  • 3
  • 27
  • 50