]> git.phdru.name Git - git-scripts.git/blobdiff - fork
Feat(ls-assumed): Recognize files with skip-worktree bit
[git-scripts.git] / fork
diff --git a/fork b/fork
index 99a84766258911f57c08a9c73ddc9fcd346161d9..09248da1bf3087dfa66a3d200bf72624aa35f402 100755 (executable)
--- 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