Questions tagged [gitpython]

0

votes
0

answer
4

Views

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 the directory amount of commits, It says the repo is...
Get Rept
1

votes
1

answer
288

Views

How to push to git using gitPython with different users

I use gitPython to push to a remote repo using different users who are logged in into our app. For now I just push to repo like below: logging.debug('Opening repo {}...'.format(repo_path)) repo = Repo(repo_path) logging.debug('Repo is initialized :)') logging.debug('git add: {} {}'.format(env, file_...
ALH
1

votes
0

answer
282

Views

GitPython check if git pull changed local files

Using GitPython and I want to call a function only if there is a change to local files after a pull. For example if I make a push on a separate computer. Then pull on the first computer it works as expected but does not provide any output. An ideal output is a list of files changed. Or alternatively...
Ryan Mills
1

votes
0

answer
77

Views

GitPython: merge remote and local branch to check if there are merge conflicts

I want to use GitPython to merge a local branch with its remote and detect if any merge conflicts have occurred. Whats the simplest way to do this? I've been read the gitPython docs and exploring the merge_tree method on the index - it seems rather complicated. Anyone know of a simpler way?
frodo
1

votes
1

answer
126

Views

I see scapy ipsec.py python code in GitHub: how do I install and use it?

There is a python module to generate IPSec packets using scapy in GitHub, but that file is not in its own .git extension to download. Please find the link for the code:https://github.com/secdev/scapy/blob/master/scapy/layers/ipsec.py How can I use that script?
Vinayak UH
1

votes
1

answer
145

Views

How to get the last commit of an specific file using python?

I tried with GitPython, but I am just getting the actual commit git hash. import git repo = git.Repo(search_parent_directories=True) repo.head.commit.hexsha But, for trazability I want to store the git commit hash of an specific file, i.e. the equivalent of this command (using git) git log -n 1 --pr...
nanounanue
1

votes
1

answer
77

Views

Working with branches in Dulwich (access objects / checkout)

I have a problem with Dulwich (switched to it from GitPython because of the well-known Windows bug with opened files in .git folder). I'm trying to get a file from another branch of currently opened repo (its state from last commit). In GitPython this task can be solved in nice and easy manner: fi...
Igor Avizov
1

votes
0

answer
16

Views

Get next-older tag for a given commit?

I'm trying to figure out the next-older tag for a given commit. I currently have the following function: def next_older_tag(commit): repo = commit.repo for tag in repo.tags: if tag.commit.committed_datetime >= commit.committed_datetime: continue return tag After consulting the docs, I could not find...
nlsdfnbch
1

votes
1

answer
253

Views

GitPython - cloning with ssh key - Host key verification failed

i have a problem with cloning git repository in my application. KEY_FILE = '/opt/app/.ssh/id_rsa' def read_git_branch(config_id, branch): config = RepoConfig.objects.get(id=config_id) save_rsa_key(Credentials.objects.get(id=1).key) git_ssh_identity_file = os.path.expanduser(KEY_FILE) git_ssh_cmd = '...
user3043817
1

votes
0

answer
33

Views

Using GitPython to download a specific version

How can I clone a repository but just using the branch, the tag or the exact commit? REPO = git.Repo.clone_from(url, tmpdirname, branch=branch Something like above download all the repository...
jonaprieto
1

votes
0

answer
17

Views

Detecting operation changes in GitPython

GitPython provides an interface for asynchronously notifying of operation progress called RemoteProgress. However, I'm having a hard time figuring out when the different operations (op_codes) begin and end. The library seems to have these BEGIN and END flags, but they never seem to be set. In update...
sssilver
1

votes
1

answer
41

Views

Git:get changes released to master over time

as a personal project, I'd like to check different python libraries and projects (be it proprietary or open source) and analyze how the code was changed over time in different releases to gather some info about the technical debt (mainly through static code analysis). I'm doing this using gitpython...
user3630290
1

votes
1

answer
180

Views

Push new local branch to remote using Gitpython

I looked at a few references but I am still having problems: SO: Pushing local branch to remote branch - gitpython SO: Use GitPython to Checkout a new branch and push to remote Related question: https://github.com/gitpython-developers/GitPython/issues/471 Tutorial: https://gitpython.readthedocs.io/e...
deckard
1

votes
2

answer
103

Views

Reading commits in reverse using GitPython

Is there a way to iterate commits in reverse using the GitPython lib, that is, from the oldest one to the newest, in a similar manner to: >>> from git import Repo >>> repo = Repo('/path/to/repo') >>> for commit in reversed(repo.iter_commits()): ... print commit ... Traceback (most recent call l...
null
1

votes
0

answer
25

Views

How to set up gitpython on in Visual Studio Code so it is setup once

I am developing on OS/X using Visual Studio Code (1.30.1). My script works but each time I close and re-open Visual Studi Code, I have to setup GitPython again. I want to set it up once and have it work. I am developing with GitPython which I set up as follows via the VS Code Terminal window: python...
Jennifer Anfaenger
1

votes
1

answer
36

Views

Git: commits by order of merge

I have written a python script that iterates through the last 10 commits in my master branch. Master branch is restricted from commit and can only be merged to. Consider the below scenario. Branch 1 has a commit done at 10.00 am with commits 1 & 2 Branch 2 has a commit done at 11.00 am with commits...
Paddy Mahadeva
1

votes
1

answer
36

Views

Want to check if repository exists and if it's public (gitpython)

Using Python and GitPython, with a list of git repositories from different users, I need to check if the repository exists and if it is public. With that in mind and thinking of GitHub, if it asks for username and password, I know that the repository is out of my criterias. Therefore, I can ignore...
iperetta
1

votes
0

answer
14

Views

gitpython - push stash with message

I am new to gitpython and want to use it to create a stash with a specific message. I know the command line syntax for this is git stash push -m 'descriptive message here', but I cannot get the same command to work from gitpython. Per the documentation on unwrapped commands, it seems like the code b...
Addison Klinke
1

votes
1

answer
580

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' traverse repo.tree() and collect all the blobs' abspath If a file was deleted in a specific commit, it wi...
Wilbert
1

votes
1

answer
1k

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.
F0UF
1

votes
2

answer
1.3k

Views

getting last git commit date via passing git command to subprocess in python

I have a script in which I just need to retrieve the date in the format 2015-07-28 of the last git commit. but using git log -1 --pretty=format:'%ci' in terminal if I get Tue Jul 28 16:23:24 2015 +0530 then if I am trying to pass this as string to subprocess.Popen like subprocess.Popen('git log -...
Ciasto piekarz
1

votes
1

answer
142

Views

GitPython: How can I pull a remote repository with '--no-ff'?

How can I translate this in python using GitPython module? git pull --no-ff
Romulus
1

votes
1

answer
475

Views

gitPython clone GitCommandError

I was testing gitPython's clone from function like this, git.Repo.clone_from('https://github.com/nicothin/web-design.git','/home/tom/src',branch='master',recursive=True) but it always gives error like, Traceback (most recent call last): File '', line 1, in File '/usr/local/lib/python2.7/dist-packag...
tomriddle_1234
1

votes
1

answer
587

Views

delete files from git using gitpython

I need to programmatically delete all versions of a particular file from git (including the commit messages from when the files was updated). The versions could be scattered throughout the list of commits. Example: if there are 10 total commits, and the file in question was updated at commit 3, 4,...
tamjd1
1

votes
2

answer
135

Views

Git pull a change of a gerrit project using gitpython

I am trying to pull a change of a gerrit project into my local repository using gitpython. This can be done using the following command, git pull origin refs/changes/25/225/1 Here, refs/changes/25/225/1 is the change that has not been submitted in gerrit. I have cloned the gerrit project into a dire...
nidHi
1

votes
1

answer
136

Views

Using gitpython to checkout-index

I'm trying to determine how to perform a git-checkout-index via gitpython, and having difficulties. I have shallow cloned the repo to a directory using git.Repo.clone_from. I now wish to export this repo and specified branch to a directory. The git cli syntax appears to be fairly straight forward....
user7102324
1

votes
1

answer
967

Views

gitpython to check for if there are any changes in files using PYTHON

I am experimenting with gitpython and I am new to it. I am trying to detect if there are any changes staged for commit. Currently, I have a function that looks like this: def commit(dir): r = Repo(dir) r.git.add(A=True) r.git.commit(m='commit all') But this is just the code to commit the directory....
decemberrobot
1

votes
1

answer
1k

Views

Git pull using GitPython + SSH keys doesn't work

I am trying to pull a repo from my Github account using GitPython. This is after (1) I performed a git clone already from the command line. (2) Generated new SSH keys using ssh-keygen -t rsa -b 4096 (3) Setup the contents of the .pub file from #2 above in Github as a new SSH key. I still get promp...
DancingJohn
1

votes
1

answer
354

Views

List the content of a directory for a specific git commit using GitPython

Using GitPython, I'm trying to list the content of a directory at a given commit (i.e. a 'snapshot' of the directory at the time). In the terminal, what I'd do is: git ls-tree --name-only 4b645551aa82ec55d1794d0bae039dd28e6c5704 How can I do the same in GitPyhon? Based on the answers I've found to a...
Jir
1

votes
3

answer
1.6k

Views

Python script to git clone without entering a password at the prompt

I am trying to clone a project from the private git repository git clone [email protected]:/Intel/BareRepos/lteue.git using the Python script. The problem with my script is I need to enter the password manually every time for cloning the project from local repository. Is there any pythonic way t...
user8339266
1

votes
3

answer
135

Views

Can't run raw git filter-branch

I'm using git-python in one of my projects, and currently I have this code: tpl = ''' if test $GIT_COMMIT = '%s'; then export GIT_AUTHOR_DATE='%s' export GIT_COMMITTER_DATE='%s' fi ''' s = '' for commit in filter(lambda x: x['newdatetime'] is not None, self.commit_datetime): s += tpl % ( commit['has...
alexandernst
1

votes
2

answer
123

Views

How to get file data from a specific git commit using gitpython

I am trying get a file from a specific commit using gitpython python-module. I'm able to get the file (with content) from the latest commit. However I want to get the file (with content) from a specific previous git commit. repo = git.Repo('G:\myrespo') obj = repo.git.get_object_data(x.a_blob) How c...
Hari K
1

votes
1

answer
42

Views

extracting git time recursivley for subfolders and files

I am trying to create a dictionary with elements in the format filename: timestamp in yy-mm-dd hh:mm:ss . This should recursively include all subfolders and files in the repo . I came across ths piece of code : import git repo = git.Repo('./repo') tree = repo.tree() for blob in tree:...
user3399495
1

votes
1

answer
115

Views

Git rebase/checkout keep the latest modified file

I want to know how to pull with rebase from the origin, and if the files have conflicts I want to keep the latest modified file. Is there a way in git to get the modified date of each file in a commit or just the commit date? Or is there a way to list the files with differences from your local branc...
1

votes
1

answer
352

Views

Push to remote repository

I have two repositories on github, using gitpython I'm trying to push a file from one repository to another remote repository. I've managed to do it using git but struggling with the gitpython code. git remote add remote_to_push [email protected] git fetch remote_to_push git checkout remote_to_push/m...
w1220
1

votes
1

answer
0

Views

Clone AWS CodeCommit git repository using GitPython with https credentials

I'm looking everywhere since for the more accurate way to clone an AWS CodeCommit git repository through python using https protocol. In fact for those who don't know aws suggest using the codecommit credential helper to generate user and password, like this : git config --global credential.helper '...
nixmind
1

votes
1

answer
2.2k

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 TMPDIR=/var/folders/BM/BMT-0W4+H5yVS5fJngFdsk+++TI/-Tmp-/ Apple_PubSub_Socket_Render=/tmp/launch-V50MvM/Render TERM_PROGRAM_VERSION=273.1 U...
paganotti
1

votes
2

answer
534

Views

Equivalent to “git tag --contains” in gitpython

I am trying to achieve git tag --contains in gitpython. Can anyone point me to the documentation. I have found documentation to fetch all tags but not with tags that contain particular commit.
pavan
1

votes
1

answer
2.4k

Views

Installing GitPython on Windows 7

I do not seem to be able to install GitPython in my windows 7 environment. I have tried both GitPython-0.1.7 and GitPython-0.3.2.RC1 on both python-2.7.8 and python-3.4.1 and all combinations cause a failure. I use 'python setup.py install' to install these packages. GitPython-0.1.7 seems to need ez...
Dave Hollingsworth
1

votes
1

answer
667

Views

HOW-TO: git show hexsha:directorypath/file

Thank you for supporting this awesome module (GitPython) that I have been working with the last couple of weeks. I tried to find in the documentation the equivalent in GitPython of how to make the call to 'git show' git show :/ even with interacting with git directly git_ = irepo.git Could you pleas...
onedreamcloser

View additional questions