Browse Source

Create gitUpload.sh

MoeClub 1 year ago
parent
commit
e53b55b8d5
1 changed files with 27 additions and 0 deletions
  1. 27 0
      gitUpload.sh

+ 27 - 0
gitUpload.sh

@@ -0,0 +1,27 @@
+#!/bin/bash
+
+target="${1:-}"
+repo="${2:-}"
+branch="${3:-main}"
+
+[ -n "${target}" ] && [ -n "${repo}" ] || exit 1
+[ -e "${target}" ] || exit 1
+tmp=$(mktemp -d)
+cd "$tmp"
+
+git init
+git checkout -b "$branch"
+git remote rm origin >/dev/null 2>&1
+git remote add origin "$repo"
+
+git pull origin "$branch"
+[ -f "${target}" ] && cp -rf "${target}" "${tmp}"
+[ -d "${target}" ] && cp -rf "${target%/}/." "${tmp}"
+
+git add .
+git commit -m `date +'%Y%m%d%H%M%S'`
+
+# git config http.postBuffer 524288000
+git push origin "$branch" -f
+
+