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
15
votes
1 answer

How to git fetch using gitpython?

I am looking for a equivalent way to fetch in gitpython git fetch --quiet --all How can I perform git fetch in python?
devops
  • 1,121
  • 5
  • 20
  • 50
14
votes
3 answers

How to create a Git Pull Request in GitPython

I am trying to use python for my jenkins job, this job downloads and refreshes a line in the project then commits and creates a pull request, I am trying read the documentation for GitPython as hard as I can but my inferior brain is not able to make…
Shek
  • 1,543
  • 6
  • 16
  • 34
14
votes
1 answer

gitpython: Command syntax for git commit

with using gitpython module, I am writing python script to check git diff --> git add of all modified files one by one. At the end I want to commit all these changes, but I didn't find the exact syntax of the command. I'm trying with below code,…
SunilThorat
  • 1,672
  • 2
  • 13
  • 15
13
votes
4 answers

How to clone from specific branch from Git using Gitpython

I tried to clone a repository from git using GitPython in python function. I used GitPython library for cloning from git in my python function and my code snippet as follows: from git import…
Antony
  • 581
  • 4
  • 7
  • 24
13
votes
2 answers

Python Git diff parser

I would like to parse git diff with Python code and I am interested to get following information from diff parser: Content of deleted/added lines and also line number. File name. Status of file whether it is deleted, renamed or added. I am using…
Mohsen Laali
  • 463
  • 1
  • 3
  • 17
13
votes
4 answers

How to checkout a tag with GitPython

In a python script, I try to checkout a tag after cloning a git repository. I use GitPython 0.3.2. #!/usr/bin/env python import git g = git.Git() g.clone("user@host:repos") g = git.Git(repos) g.execute(["git", "checkout", "tag_name"]) With this…
Nicolas BOISSINOT
  • 131
  • 1
  • 1
  • 3
12
votes
1 answer

Using gitpython, how can I checkout a certain Git commit ID?

Checking out a branch works well, but I also need to check out a certain commit ID in a given Git repository. I mean the equivalent of git clone --no-checkout my-repo-url my-target-path cd my-target-path git checkout my-commit-id How can I do this…
eerriicc
  • 1,124
  • 4
  • 17
  • 29
12
votes
4 answers

Retrieve Github repository name using GitPython

Is there a way to get the repository name using GitPython? repo = git.Repo.clone_from(repoUrl, ".", branch=branch) I can't seem to find any properties attached to the repo object which has this information. It might be that I misunderstand how…
erihanse
  • 342
  • 1
  • 4
  • 11
12
votes
5 answers

GitPython create and push tags

In a python script, I try to create and push a tag to origin on a git repository. I use gitpython-1.0.2. I an able to checkout anexisting tag but no way to find how to push a new tag to remote. Many thanks
Thzith
  • 409
  • 1
  • 3
  • 8
12
votes
2 answers

GitPython: Get current tag (detached head)

I use the library gitpython If the local git is on a checked out tag, I want to get the name of the tag. repo=git.Repo(repo_dir) repo.tag # --> tags. But which is the current? On the command line, the git tool knows it. Example user@host> git…
guettli
  • 25,042
  • 81
  • 346
  • 663
12
votes
1 answer

GitPython: how to commit updated submodule

I have been at this for hours now, and although I have a feeling I'm close I can't seem to figure this out. I'm trying to make a script that takes a git repository, updates a submodule in that repository to a specified version, and commits that…
Bob Vork
  • 2,927
  • 28
  • 32
11
votes
1 answer

GitPython -- How to 'git stash' changes to a GitPython repository?

I have a repo created via GitPython library that has some uncommitted changes. I want to stash those changes. How do I do it? Searching for "stash" in the GitPython docs returned no results.
Saheel Godhane
  • 313
  • 4
  • 14
10
votes
0 answers

How do I use a GitHub access token with GitPython?

I am trying to write a python script that when run, will push files to one of my GitHub repositories. I'm using the package GitPython. I want to use an access token to log in into my GitHub account (instead of entering my username and password)…
polk54
  • 111
  • 1
  • 3
10
votes
4 answers

GitPython list all files affected by a certain commit

I am using this for loop to loop through all commits: repo = Repo("C:/Users/shiro/Desktop/lucene-solr/") for commit in list(repo.iter_commits()): print commit.files_list # how to do that ? How can I get a list with the files affected from this…
dimitris93
  • 4,155
  • 11
  • 50
  • 86
10
votes
1 answer

How to stage changes with gitpython

Does anyone know what the equivalent of git commit -a is in gitpython? I have tried repo.index.commit, but don't see how to add the -a option. repo.index.add adds only new files, not existing files that have been modified. It doesn't seem to…
EvertW
  • 1,160
  • 9
  • 18
1
2
3
32 33