def init_bare(self, path, mkdir=True, **kwargs): """ Initialize a bare git repository at the given path ``path`` is the full path to the repo (traditionally ends with /<name>.git) ``mkdir`` if specified will create the repository directory if it doesn't already exists. Creates the directory with a mode=0755. ``kwargs`` is any additional options to the git init command Examples:: git.Repo.init_bare('/var/git/myrepo.git') Returns ``git.Repo`` (the newly created repo) """ if mkdir and not os.path.exists(path): os.makedirs(path, 0755) git = Git(path) output = git.init('--bare', **kwargs) return Repo(path)
def init_bare(self, path, mkdir=True, **kwargs): """ Initialize a bare git repository at the given path ``path`` is the full path to the repo (traditionally ends with /<name>.git) ``mkdir`` if specified will create the repository directory if it doesn't already exists. Creates the directory with a mode=0755. ``kwargs`` keyword arguments serving as additional options to the git init command Examples:: git.Repo.init_bare('/var/git/myrepo.git') Returns ``git.Repo`` (the newly created repo) """ if mkdir and not os.path.exists(path): os.makedirs(path, 0755) git = Git(path) output = git.init('--bare', **kwargs) return Repo(path)
def init(cls, path=None, mkdir=True, **kwargs): """ Initialize a git repository at the given path if specified ``path`` is the full path to the repo (traditionally ends with /<name>.git) or None in which case the repository will be created in the current working directory ``mkdir`` if specified will create the repository directory if it doesn't already exists. Creates the directory with a mode=0755. Only effective if a path is explicitly given ``kwargs`` keyword arguments serving as additional options to the git-init command Examples:: git.Repo.init('/var/git/myrepo.git',bare=True) Returns ``git.Repo`` (the newly created repo) """ if mkdir and path and not os.path.exists(path): os.makedirs(path, 0755) # git command automatically chdir into the directory git = Git(path) output = git.init(**kwargs) return Repo(path)