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.

  • Why does Git say my master branch is “already up to date” even though it is not?
  • Which DVCS work best with Subversion repositories
  • Fatal : The remote end hung up unexpectedly libcurl result = 7
  • Push to a non-bare Git repository
  • How to push all annotated tags?
  • remove all binary files recursively from git repo and commit history
  • 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).

    Thanks.

  • How to use docker for deployment and development?
  • Switching branches in Visual Studio 2015
  • How to connect unconnected git histories?
  • Append the commit message automatically to the file being committed in Git
  • Git Subtree Specific Ignoring
  • Why git under cygwin asks for password?
  • 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:

    When git fetch is used with <rbranch>:<lbranch> refspec, it refuses to
    update the local branch <lbranch> unless the remote branch <rbranch>
    it fetches is a descendant of <lbranch>. This option overrides that
    check.

    Git Baby is a git and github fan, let's start git clone.