git: allow force checkouts for git repository

This commit is contained in:
Marcin Kuzminski 2018-01-23 22:06:41 +01:00
parent 5c4f5f9f2c
commit 0bc9813397

View file

@ -701,7 +701,7 @@ class GitRepository(BaseRepository):
stdout, _ = self.run_git_command(['rev-parse', '--abbrev-ref', 'HEAD'])
return stdout.strip()
def _checkout(self, branch_name, create=False):
def _checkout(self, branch_name, create=False, force=False):
"""
Checkout a branch in the working directory.
@ -715,6 +715,8 @@ class GitRepository(BaseRepository):
raise RepositoryError('Cannot checkout branches in a bare git repo')
cmd = ['checkout']
if force:
cmd.append('-f')
if create:
cmd.append('-b')
cmd.append(branch_name)