Avoid deletion of repository directory in repository_ctx

On Windows, it is impossible to delete a directory while this directory
is the working directory of a running process. In _clone_or_update,
however, BAZEL_SH is called from the repository_ctx, giving it the
repository directory as working directory. The cleaning of the directory
is then performed by deleting and re-creating that very directory.

Cygwin apparently does some workarounds to make this possible, but other
shells (e. g. busybox-w32) don't. This commit changes the rule to use
the capabilities of git to achieve the same effect (completely wiping
the directory and fetching it again from the remote, like
rm -rf && git clone would.

Fixes #7274.

Closes #7285.

PiperOrigin-RevId: 232310366
diff --git a/tools/build_defs/repo/git.bzl b/tools/build_defs/repo/git.bzl
index daace56..d766911 100644
--- a/tools/build_defs/repo/git.bzl
+++ b/tools/build_defs/repo/git.bzl
@@ -50,6 +50,7 @@
               ))
     bash_exe = ctx.os.environ["BAZEL_SH"] if "BAZEL_SH" in ctx.os.environ else "bash"
     st = ctx.execute([bash_exe, "-c", """
+cd {working_dir}
 set -ex
 ( cd {working_dir} &&
     if ! ( cd '{dir_link}' && [[ "$(git rev-parse --git-dir)" == '.git' ]] ) >/dev/null 2>&1; then