Skip to content

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

Open
@dseeni

Description

@dseeni

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions