GitPython is a python library used to interact with Git repositories
1
vote
0answers
21 views
How do I set the git username and password when using gitpython?
I am planning on utilizing GitPython for my project. When I test it out, using this code I am receiving an error.
repo.index.add(['*'])
repo.index.commit(message="Initial Commit")
...
0
votes
1answer
27 views
GitPython returns exit status of 1 when trying to commit
I am attempting to automatically push changes to data files to a git repository. This script lives in the same repository as the modified data files. Below is a simple example of what I'm attempting. ...
0
votes
1answer
23 views
get dictionary of files and directories from git repository
I'm trying to get dictionary of directories and files from git repository like this:
{"dir1": ["file1", "file2", "dir2", "dir3"], "dir2": {"file3", "dir4"}}
I know how to get list of files, the ...
0
votes
1answer
26 views
Retrieving versions of a file
Say I have a path to a git repository in the local filesystem: path_to_my_repository, and a path to a file in the repository path_to_file.
For a given list of dates, how can I get the corresponding ...
1
vote
0answers
17 views
GitPython push JSON truncation
I'm using the following in Windows to push a file to git (using GitPython) that has been dumped by the JSON library:
json.dump(data, json_output,sort_keys=True)
repo.git.add("test.json")
...
0
votes
0answers
25 views
How do I delete a temp directory on Windows after using gitpython?
I have the following Python function, which I am running on Windows 7:
def update():
temp_dir = tempfile.mkdtemp()
git.Git().clone('my_repo', temp_dir)
try:
repo = ...
0
votes
0answers
31 views
How to perform automated build test using gitpython.?
I have been asked to write a code to perform some automated build
test via version control using gitpython.Please share if someone knows how to do aumated build in python.
0
votes
0answers
29 views
How do I emulate GitPython Repo tree?
We use git repositories to fill some objects in the database with the GitPython module. User enters a git repository url, we do the Repo.clone_from, iterate over the repo.tree(), fill the object ...
0
votes
1answer
62 views
Using GitPython, how do I do git submodule update --init
My code so far is working doing the following. I'd like to get rid of the subprocess.call() stuff
import git
from subprocess import call
repo = git.Repo(repo_path)
...
2
votes
2answers
127 views
how to pull, push with remote branch
I'm trying to automate a change process which currently creates source code that gets manually pushed to Git. I'm trying to wrap that code using GitPython:
from git import *
# create the local repo
...
1
vote
1answer
30 views
Equivalent to “git tag --contains” in gitpython
I am trying to achieve git tag --contains <commit> in gitpython. Can anyone point me to the documentation. I have found documentation to fetch all tags but not with tags that contain particular ...
1
vote
1answer
91 views
advantage of gitPython over executing git command with subprocess?
I recently made a git command using python that executes git command using subproces.Popen so I am debating whether to take advantage of gitPython module or not ? Does it make any difference if ...
0
votes
1answer
43 views
how do I emulate read and update git global config file using gitPython?
I want to reads git global config file using git config --list, so I can use to read and update the global config file ?
0
votes
1answer
50 views
how to do a git diff of current commit with last commit using gitpython?
I am trying o grasp gitpython module,
hcommit = repo.head.commit
tdiff = hcommit.diff('HEAD~1')
but tdiff = hcommit.diff('HEAD^ HEAD') doesn't work !! neither does ('HEAD~ HEAD').,
I am trying to ...
0
votes
1answer
136 views
How i can clone my the git repository using Python and PyGithub/GitPython?
Here I was looking around write some code through which I can maintain my git repository.
I am python beginners level but i know it. My repository on git hub is.
...
0
votes
1answer
76 views
GitPython - cannot get index for repo?
How on earth does one get the index for a repos using GitPython ?
import git
repo = git.Repo.init('/path/to/repos/')
... add some files ...
... commit ...
index = repo.index()
Throw error: 'Repo' ...
1
vote
0answers
186 views
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)
...
1
vote
3answers
270 views
gitpython and git diff
I am looking to get only the diff of a file changed from a git repo. Right now, I am using gitpython to actually get the commit objects and the files of git changes, but I want to do a dependency ...
0
votes
0answers
57 views
Using (or abusing?) GitPython
I've created a custom widget in wxPython which though not yet perfect, is good enough to add to one of my projects (call this widget v1.). I want to keep working on/experimenting with the widget, but ...
2
votes
3answers
494 views
Finding the first commit on a branch with GitPython
I'm writing a git post-receive hook using Python and Git-Python that gathers information about the commits contained in a push, then updates our bug tracker and IM with a summary. I'm having trouble ...
0
votes
1answer
336 views
Does GitPython works with Python 3.x?
If "yes", is there any difference when it's used with Python 2. ?
I found this, but I would say the answer isn't clear for me.
Thanks.
1
vote
1answer
103 views
GitPython: Determine files that were deleted in a specific commit
Using gitpython, I am trying to get a list of changed paths; that is, of all the added, changed and deleted files.
I can retrieve the changed and added files from the commit:
checkout commit 'X'
...
2
votes
1answer
132 views
How to get count of unpublished commit with GitPython?
With git status I can get information about count of unpublished commits:
» git status
# On branch master
# Your branch is ahead of 'origin/master' by 2 commits.
# (use "git push" to ...
0
votes
1answer
190 views
How can I specify the committed_date of a Commit using GitPython?
I would like to commit a file with a custom date.
So far I've created a Commit object, but I don't understand how to bind it to a repo.
from git import *
repo = Repo('path/to/repo')
comm = ...
1
vote
1answer
217 views
Edit a commit with gitpython
Lets say you're in the terminal, currently sitting at the root of a git repo.
If you've got GitPython installed, you can do this to get the last committed commit, or rather, the commit that HEAD ...
2
votes
1answer
262 views
gitpython error when checking if repo is dirty
I receive an error while trying to use gitpython to check if a repository is dirty, i.e. has uncommitted changed to tracked files:
import git
repo = git.Repo('')
print repo.is_dirty()
The error:
...
2
votes
1answer
105 views
gitpython creating zip archive
How can I create an archive with gitpython, I tried the following which creates the file but I can't open it it tells me an error occurred reading archive the archive appears to be invalid or damaged
...
1
vote
1answer
1k views
How can I pull a remote repository with GitPython?
I am trying to find the way to pull a git repository using gitPython.
So far this is what I have taken from the official docs in ...
2
votes
0answers
238 views
GitPython equivalent of “git remote show origin”?
I'm trying to update a Python script that checks the status of a handful of local repositories against remotes from using subprocess to using GitPython. What is the equivalent command in GitPython for ...
2
votes
1answer
661 views
GitPython create local branch from remote branch
I have multiple lab machines and I need to make a copy of my remote branch on my local lab machine. I believe the git bash command for this is:
git checkout -b mybranch origin/mybranch
How do I ...
1
vote
2answers
255 views
How to do a git reset --hard using gitPython?
Well the title is self explanatory. What will be the python code equivalent to running git reset --hard (on terminal) using GitPython module?
1
vote
2answers
714 views
how to automate a push to repo using gitpython
I am trying to make a python script which would check for changes in my git local working folder, and automatically push them to the online repo. Currently only using git manually to do it. I want to ...
2
votes
2answers
435 views
cannot follow the python git tutorials
I have lately installed python-git package, and when trying to follow the tutorials over at the following link, I find that certain methods are missing...
...
3
votes
1answer
801 views
Using GitPython module to get remote HEAD branch
I'm trying to use GitPython to write some Python scripts which I can use it to simplify my daily tasks as I manage many branches.
I'm also quite new for Python when it comes to writing complicated ...
0
votes
1answer
2k views
OSError: [Errno 2] No such file or directory on GitPython
I am using GitPython to fetch a remote repository to my machine. The following code works well on my Ubuntu 12.04 but on my amazon ec2, on a Ubuntu 11.10 server, I get the OSError: [Errno 2] No such ...
4
votes
2answers
479 views
GitPython get tree and blob object by sha
I'm using GitPython with a bare repository and I'm trying to get specific git object by its sha. If I used git directly, I would just do this
git ls-tree sha_of_tree
git show sha_of_blob
Since I'm ...
2
votes
1answer
202 views
Checking if an object is in a repo in gitpython
I'm working on a program that will be adding and updating files in a git repo. Since I can't be sure if a file that I am working with is currently in the repo, I need to check its existence - an ...
1
vote
2answers
453 views
How do you define the host for Fabric to push to GitHub? (updated)
Original Question
I've got some python scripts which have been using Amazon S3 to upload screenshots taken following Selenium tests within the script.
Now we're moving from S3 to use GitHub so I've ...
6
votes
1answer
1k views
git log --follow, the gitpython way
I am trying to access the commit history of a single file as in:
git log --follow -- <filename>
I have to use gitpython, so what I am doing now is:
import git
g = git.Git('repo_dir')
...
1
vote
1answer
587 views
python doesn't get environment variable but it is set on mac os
if I run env command I obtain this output:
TERM_PROGRAM=Apple_Terminal
GPG_AGENT_INFO=/Users/paganotti/.gnupg/S.gpg-agent:346:1
TERM=xterm-color
SHELL=/bin/bash
...
2
votes
1answer
750 views
GitPython: get list of remote commits not yet applied
I am writing a Python script to get a list of commits that are about to be applied by a git pull operation. The excellent GitPython library is a great base to start, but the subtle inner workings of ...
0
votes
1answer
216 views
Reverting local changes to a file using GItPython
Is there a way under the GitPython library to revert local changes to a single file?
Under the Git command line I would just use git checkout filename but attempting to do this under the GitPython ...
1
vote
1answer
267 views
Get all commits when pushing to server
I am making a git post-commit hook to post my commit messages to Twitter. I have set up the hook on the server, which means it only runs when I call git push.
To interface with git from python, I am ...
2
votes
1answer
653 views
Git Python Cannot find Commit
I am not able to find a commit that a tag points to by navigating the commit tree. For this specific example, I am using the Tornado Web repository cloned directly from Github.
import sys
import git
...
11
votes
2answers
2k views
Python os.getlogin problem
If i create a file like:
import os
print os.getlogin()
and run it with cron, I get an exception
print os.getlogin()
OSError: [Errno 22] Invalid argument
If I run it manually in shell -- it ...
4
votes
1answer
654 views
How to import the Python async module from a worker thread?
I'm using the GitPython package to access a Git repository from Python. This pulls in the async package. In async/__init__.py, the following happens:
def _init_signals():
"""Assure we shutdown ...
0
votes
2answers
351 views
Can a bare repository have an index? Is this a bug?
I'm trying to get GitPython 0.3 to commit a file to a repository. Roughly, I'm doing this as follows:
data = ...
istream = repo.odb.store(gitdb.IStream(git.Blob.type, len(data), StringIO(data)))
...