git is a library that can be used to run git commands in python.
Paste git.py file in the Lib folder of the path retreved from os.path.dirname(sys.executable)
import git
# clones repository from the "url"
git.clone(url)# initialize empty repository on current location
git.gitinit()# adds files to the stage from the "path".
git.addtostage(path)#remove "file" from staging area
git.rmstage(file)#commits with the "message"
git.commit(message)'''
origin - add the remote point name
url - add url to connect with remote repositary
'''
git.add_origin(origin,path)'''
origin - mantion the remote point name to push
branch - branch name from where to push"""
'''
git.push(origin,path)from git import statusTo get modified files use:
status.modified()To get cached files use:
status.cached()To get untracked files use:
status.untracked()To get deleted files use:
status.deleted()To get staged files use:
status.staged()#importing log class from git library
from git import loglog.commit_data() function can be used to find particular log details based on its commit id or commit message.
# Using commit Message:
log().commit_data('Create README.md')
# Using commit ID:
log().commit_data('70bca60c7a99f7cb10d9beb6d4550d6904a012a9')