X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=git-publish-branch;fp=git-publish-branch;h=74584e60b255513ed8aeecf4f1178fb4f64d2749;hb=d1f483d7d69d2fa7589cb5d850a896dc46db33f8;hp=4986c363d9c5d3f02d61c1714e560c0acba7088b;hpb=d0750a70c888c1172a9cf1c0606b490434774e5d;p=git-utils.git diff --git a/git-publish-branch b/git-publish-branch index 4986c36..74584e6 100755 --- a/git-publish-branch +++ b/git-publish-branch @@ -2,9 +2,13 @@ # git-publish-branch [-d] [branch] [repository] unset delete +unset force if [ "$1" = "-d" ]; then delete=1 shift +elif [ "$1" = "-f" ]; then + force=1 + shift fi unset branch @@ -47,6 +51,27 @@ if [ $delete ]; then git config --unset "branch.$branch.merge" git config --unset "branch.$branch" fi +elif [ $force ]; then + if [ -z "$local_ref" ]; then + echo "no local branch $branch" >&2 + exit 1 + elif [ -z "$remote_ref" ]; then + echo "$remote has no branch $branch" >&2 + exit 1 + elif [ -z "$remote_config" ]; then + echo "local branch $branch is not a tracking branch" >&2 + exit 1 + fi + + # Delete the remote branch + if [ -n "$remote_ref" ]; then + git push "$remote" ":refs/heads/$branch" + else + echo "$remote has to remote branch $branch" >&2 + fi + + # Push the new branch + git push "$remote" "+$branch:refs/heads/$branch" else if [ -z "$local_ref" ]; then echo "no local branch $branch" >&2