BitbucketBackup – Overcome Git fetch non-fast-forward error
I am using BitBucket Backup to backup my team’s repository locally.
It works fine. Except that recently I was cleaning up old repositories (that came from CVS and SVN) and while doing that I had rebased the repositories in bitbucket.
As a result Bitbucket Backup is not updating my local copy.
It uses the command
git fetch <repo url> refs/heads/*:refs/heads/* refs/tags/*:refs/tags/*.
It fails with error
[rejected] master –> master (non-fast-forward)
That makes total sense, and it would be fine for a human user, but somehow I need to tell the git fetch that if it gets a non-fast-forward error to kill the local repository and just download everything from scratch.
Is there such an option for git fetch?
Otherwise I would need to detect the issue in Bitbucket Backup and clean up the folder myself (but that would be more involved).
One Solution collect form web for “BitbucketBackup – Overcome Git fetch non-fast-forward error”
Yes, there’s such an option:
--force (or just
-f). Quoting the doc:
git fetchis used with
<rbranch>:<lbranch>refspec, it refuses to
update the local branch
<lbranch>unless the remote branch
it fetches is a descendant of
<lbranch>. This option overrides that