diff --git a/git-mirror.sh b/git-mirror.sh index 4e48474..81dab19 100755 --- a/git-mirror.sh +++ b/git-mirror.sh @@ -81,6 +81,7 @@ for branchspec in "${branches[@]}"; do set $branchspec leader_sha="$1" branch="$2" + if [ "$branch" = HEAD ]; then continue; fi for remote in "${followers[@]}"; do echo @@ -90,7 +91,7 @@ for branchspec in "${branches[@]}"; do if ! ref_exists "$follower_ref"; then echo "Branch doesn't yet exist at remote, creating" - git reset --hard "$leader_sha" -- + git checkout "$leader_sha" -- git push "$remote" "+HEAD:$branch" || { error "$remote $branch: failed to push"; continue; } elif is_ref_at_sha "$follower_ref" "$leader_sha"; then @@ -98,7 +99,7 @@ for branchspec in "${branches[@]}"; do else echo "Branch exists at remote, updating" - git reset --hard "$follower_ref" -- + git checkout "$follower_ref" -- git merge --ff-only "$leader_sha" || { error "$remote $branch: FF not possible"; continue; } git push "$remote" "+HEAD:$branch" || { error "$remote $branch: failed to push"; continue; } fi