浏览代码

Add files via upload

MoeClub 4 月之前
父节点
当前提交
1a3930e5a5
共有 1 个文件被更改,包括 12 次插入10 次删除
  1. 12 10
      gitUpload.sh

+ 12 - 10
gitUpload.sh

@@ -6,7 +6,8 @@ branch="${3:-main}"
 clone="${4:-}"
 
 [ -n "${target}" ] && [ -n "${repo}" ] || exit 1
-tmp="$(mktemp -d)"
+# [ -e "${target}" ] || exit 1
+tmp=$(mktemp -d)
 trap "rm -rf ${tmp}" EXIT
 cd "$tmp"
 
@@ -27,21 +28,22 @@ git init
 git checkout -b "$branch"
 git remote rm origin >/dev/null 2>&1
 git remote rm clone >/dev/null 2>&1
-[ "$repo" != "-" ] && {
-  git remote add origin "$repo"
-  git pull origin "$branch"
-}
-[ -n "$clone" ] && {
-  git remote add clone "$clone"
-  createRepo "$clone"
-}
-
+git remote add origin "$repo"
 
+git pull origin "$branch"
 [ -n "${target}" ] && [ "${target}" != "-" ] && {
   [ -f "${target}" ] && cp -rf "${target}" "${tmp}"
   [ -d "${target}" ] && cp -rf "${target%/}/." "${tmp}"
 }
 
+[ -n "$clone" ] && {
+  rm -rf .git
+  git init
+  git checkout -b "$branch"
+  git remote add clone "$clone"
+  createRepo "$clone"
+}
+
 [ "${target}" == "-" ] && read -p "Pause <${tmp}> ..."
 
 git add .