From 613ea3d08cd15607d06f669e1bbf458c1f279d29 Mon Sep 17 00:00:00 2001 From: Alpyne Date: Tue, 21 Jul 2020 21:55:32 -0700 Subject: [PATCH] WSL compatibility for create-branch.sh --- create-branch.sh | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/create-branch.sh b/create-branch.sh index 85843a5..92c8284 100755 --- a/create-branch.sh +++ b/create-branch.sh @@ -1,17 +1,23 @@ -#!/usr/bin/env bash - -# USAGE: bash create-branch.sh - -# new branch -echo "Creating branch '$1'" -git branch -D $1 || true -git checkout $2 $1 -git reset - -echo "Committing changes..." -git add src -git add client.txt -git commit -m "Update to $1" - -echo "Pushing to origin..." -git push --force origin $1 +#!/usr/bin/env bash + +# USAGE: bash create-branch.sh + +gitcmd="git" +if uname -r | grep Microsoft > /dev/null; then + echo WSL Detected: Using git.exe + gitcmd="git.exe" +fi + +# new branch +echo "Creating branch '$1'" +$gitcmd branch -D $1 || true +$gitcmd checkout $2 $1 +$gitcmd reset + +echo "Committing changes..." +$gitcmd add src +$gitcmd add client.txt +$gitcmd commit -m "Update to $1" + +echo "Pushing to origin..." +$gitcmd push --force origin $1