pygit2 icon indicating copy to clipboard operation
pygit2 copied to clipboard

Support: How can I access the commit history of a bare git repo from pygit2 (article linked)

Open dseeni opened this issue 5 years ago • 0 comments

Hi libgit2,

I'm fairly new to coding so forgive me if this is a bit of stupid question. I'm working on a script that helps automate the adding and commit of a large list of files to a bare git repo (following the article below). When I try to access the status or history of the bare git repository from bash, the below command and aliasing works fine.

I understand pygit2 has no knowledge of the alias, but I have been trying for days to find the commands for git dir and --work-tree... to get me the same results in the api. There are a few in the api but nothing seems to let me easily check out branches, see their status, add files since the repository is bare? Can anyone provide some clarity on if this workflow is possible form a python git api. GitPython seems to have the same issues.. it could just be me or ?

This is what I'm trying to do, but from python: https://harfangk.github.io/2016/09/18/manage-dotfiles-with-a-git-bare-repository.html

This is the bash alias that makes working and adding files to the bare git repostory possible, as well as git status etc: echo 'alias dotfiles="/usr/bin/git --git-dir=$HOME/.dotfiles.git/ --work-tree=$HOME"' >> $HOME/.zshrc

How do I create this from pygit2 OR gitpython? I need to be able to check status, add, commit, remove from branch a bunch of files and I would like to do it within my python program.

dseeni avatar Feb 09 '20 06:02 dseeni