Skip to content

Commit fed94b1

Browse files
author
Victor Arribas
committed
bin: add git-mirror-branch
1 parent c4129c9 commit fed94b1

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

bin/git-mirror-branch

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (c) 2020
4+
# Author: Victor Arribas <[email protected]>
5+
# License: GPLv3 <http://www.gnu.org/licenses/gpl-3.0.html>
6+
#
7+
# Usage:
8+
# git mirror-branch <branch name> <remote origin> <remote target>
9+
10+
set -e
11+
set -u
12+
13+
usage(){
14+
cat<<EOF
15+
git-mirror-branch
16+
Copyright (c) 2020, Victor Arribas <[email protected]>
17+
18+
Push a branch from one remote to another without touch working tree.
19+
Usage: git mirror-branch <branch name> <remote origin> <remote target>
20+
21+
EOF
22+
}
23+
24+
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
25+
usage
26+
exit 1
27+
fi
28+
29+
branch=$1
30+
origin=$2
31+
target=$3
32+
git push "$target" "$origin/$branch":"refs/heads/$branch"

0 commit comments

Comments
 (0)