X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=fork;h=09248da1bf3087dfa66a3d200bf72624aa35f402;hb=68dcecea7c125ced02c18fa641c21ac5d3ce05aa;hp=99a84766258911f57c08a9c73ddc9fcd346161d9;hpb=820288d1b046f3023b4f5267630e3d5307c90981;p=git-scripts.git diff --git a/fork b/fork index 99a8476..09248da 100755 --- a/fork +++ b/fork @@ -9,20 +9,30 @@ upstream="$1" origin="$2" local_repo="`basename \"$origin\" .git`" -git clone -o upstream "$upstream" "$local_repo" && -cd "$local_repo" && -git remote add origin "$origin" && +if [ -d "$local_repo"/.git ]; then + cd "$local_repo" +fi && -chmod a-x .git/config && -branch="`git branch | awk '/^\*/ {print $2}'`" && +if [ -d .git ]; then + git remote add upstream "$upstream" + git remote set-url origin "$origin" || git remote add origin "$origin" +else + git clone -o upstream "$upstream" "$local_repo" && + cd "$local_repo" && + chmod a-x .git/config && + git remote add origin "$origin" +fi && +pwd >> "`dirname \"$0\"`"/locate-all.list && +branch="`git rev-parse --abbrev-ref HEAD`" && + +git pull upstream $branch && git pull origin $branch && -git push -u origin && +git push -u origin $branch && git config branch.$branch.remote upstream && git config branch.$branch.remotepush origin && git config branch.$branch.merge refs/heads/$branch && git config push.default current && -git gc --aggressive && -exec pwd >> "`dirname \"$0\"`"/locate-all.list +exec git gc --aggressive