# HG changeset patch # User Marcin Kuzminski # Date 2018-01-23 21:06:41 # Node ID 676bf7b7a789c771f020f49cf4a06c1d6c5c72b0 # Parent f1478d29a7453d4ade3e83c6a5e99e88b7f73a27 git: allow force checkouts for git repository diff --git a/rhodecode/lib/vcs/backends/git/repository.py b/rhodecode/lib/vcs/backends/git/repository.py --- a/rhodecode/lib/vcs/backends/git/repository.py +++ b/rhodecode/lib/vcs/backends/git/repository.py @@ -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)