git: allow force checkouts for git repository
This commit is contained in:
parent
5c4f5f9f2c
commit
0bc9813397
1 changed files with 3 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue