Questions tagged [pygit2]

Pygit2 is a set of Python bindings to the libgit2 shared library.

Pygit2 is a set of Python bindings to the libgit2 shared library, libgit2 implements the core of Git. Pygit2 works with Python 2.6, 2.7, 3.1, 3.2 and 3.3

Pygit2 links:

82 questions
28
votes
4 answers

How to get the current checked out Git branch name through pygit2?

This question should be related to: How to get the current branch name in Git? Get git current branch/tag name How to get the name of the current git branch into a variable in a shell script? How to programmatically determine the current checked…
Drake Guan
  • 14,514
  • 15
  • 67
  • 94
15
votes
2 answers

Create a commit using pygit2

I would like to make a commit on a branch (master for example). I am making a repository clone using pygit2 (pygit2.clone_repository) Then I change an existing file in the repository. Afterwards I run this to make a commit: index =…
user1479699
  • 153
  • 1
  • 5
13
votes
4 answers

Git Commit Parents' Order

Is there some convention for the order of a commit's parents? Because one of the commit's parents should be to be to previous commit on the current branch that is being merged into and the rest are previous commits of the other merging branches. I…
Emil Davtyan
  • 13,808
  • 5
  • 44
  • 66
12
votes
1 answer

Create, Clone, and Push to GitHub repo using PyGitHub and PyGit2

How can I create a new GitHub repository, clone it, change files, and then push it back to github using python and the pyGitHub and pyGit2 libraries? The documentation for both libraries is very sparse and there are almost no examples.
Bar Smith
  • 797
  • 6
  • 20
6
votes
2 answers

How do you checkout a branch with pygit2?

I want to use pygit2 to checkout a branch-name. For example, if I have two branches: master and new and HEAD is at master, I would expect to be able to do: import pygit2 repository = pygit2.Repository('.git') repository.checkout('new') or…
nebffa
  • 1,529
  • 1
  • 16
  • 26
5
votes
1 answer

Implementing Pull with Pygit2

I am trying to implement some 'porcelain' commands using pygit2. It seems that I have run into a bit of road block while implementing pull. Specifically the easiest pull case, a fast forward. Setup: I have two git repos. One 'remote' and one…
Michael Boselowitz
  • 3,012
  • 1
  • 19
  • 22
5
votes
1 answer

Untracked dirs on commit with pygit2

I'm working on a non-bare repository with pygit2 index = repo.index index.read() # write in test/test.txt index.add('test/test.txt') treeid = index.write_tree() repo.create_commit( 'HEAD', author, committer, 'test commit', …
linkdd
  • 1,015
  • 1
  • 10
  • 24
4
votes
2 answers

Replicating "git checkout with PyGit2

I am trying to replicate the behaviour of the command "git checkout (commit)" where (commit) is the reference to as specific commit and not a branch name. When using this command, the 'HEAD' of the repository point to the commit (detached head) and…
Maeln
  • 370
  • 1
  • 21
4
votes
0 answers

How to rebase with pygit2?

I'm stuck trying to implement a git rebase with pygit2. Assuming this repo history, how to rebase topic on master using pygit2 ? (ie, the equivalent of git rebase master topic): A---B---C topic / D---E---F---G master According to pygit2…
skadge
  • 121
  • 7
4
votes
1 answer

Pygit2: Why does merge leave branch in an unclean state?

I'm currently running Pygit 0.24.1 (along with libgit 0.24.1), working on a repository where I have two branches (say prod and dev). Every change is first commited to the dev branch and pushed to the remote repository. To do that, I have this piece…
nKn
  • 13,691
  • 9
  • 45
  • 62
4
votes
3 answers

Difference between "(no branch)" and "(detached at abc1234)"

Normally when you run something like this inside of a git repository: git checkout abc1234 You end up in a detached HEAD state. If you run git branch, the output will look something like this: * (detached from abc1234) master This is fine and…
Matthew G
  • 1,090
  • 2
  • 14
  • 23
3
votes
3 answers

How to know if a git repository is clean with Python3 (pygit2)?

I'm trying to determine if a or git commit is needed in a git repository. I come up with this code that works fine for me : def is_dirty(repo): import pygit2 status = repo.status() for filepath, flags in status.items(): if flags !=…
Laurent Claessens
  • 547
  • 1
  • 3
  • 18
3
votes
1 answer

pygit2 clone_repository authentication required but no callback set

I'm trying to clone a repository from stash using an ssh link. I get an error saying authentication is required, This should not require a username and password. How do I fix this error? from pygit2 import * repo_name =…
3
votes
2 answers

Extract commits related to code changes from commit tree

Right now I am able to traverse through the commit tree for a github repository using pygit2 library. I am getting all the commits for each file change in the repository. This means that I am getting changes for text files with extensions .rtf as…
Zack
  • 2,078
  • 10
  • 33
  • 58
3
votes
1 answer

How to set the credentials in pygit2.clone_repository?

When I clone a repo from github by pygit2, it returns: 'OSError: Failed to send request: A security error occurred' The code is simple, import pygit2 username = 'MyGitHubUsername' password = 'MyGitHubPassword' cred = pygit2.UserPass(username,…
user3196254
  • 115
  • 1
  • 6
1
2 3 4 5 6