fix: git switch fetches remote branch if it doesn't exist on remote
ci/woodpecker/push/woodpecker Pipeline failed Details

automatically

src: https://stackoverflow.com/questions/9537392/git-fetch-remote-branch
pull/6/head
Aravinth Manivannan 2022-04-16 13:19:33 +05:30
parent 99b0d49f5c
commit db1e89cd70
Signed by: realaravinth
GPG Key ID: AD9F0F08E855ED88
1 changed files with 3 additions and 2 deletions

View File

@ -104,8 +104,8 @@ deploy() {
git checkout --orphan $1 git checkout --orphan $1
else else
echo "[*] Deployment branch $1 exists, pulling changes from remote" echo "[*] Deployment branch $1 exists, pulling changes from remote"
git pull origin $1 --force git fetch origin $1
git checkout $1 git switch $1
fi fi
git rm -rf . git rm -rf .
@ -114,6 +114,7 @@ deploy() {
git add --all git add --all
if [ -n $(git status --porcelain) ]; if [ -n $(git status --porcelain) ];
then then
echo "[*] Repository has changed, committing changes"
git commit \ git commit \
--author="$3" \ --author="$3" \
--message="new deploy: $(date --iso-8601=seconds)" --message="new deploy: $(date --iso-8601=seconds)"