Skip to content

fix remote repository update #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions github.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,26 @@ fi

# Checkout the repo & enter it
if [ -d "${REPO_LOCATION}" ]; then
cd $REPO_LOCATION
git checkout master;
git pull;
# Repo already exists
cd "$REPO_LOCATION"
# Cleanup current working tree including untracked files
git reset --hard HEAD
git clean -dx --force
# Detach in case we're on a local branch
git checkout --detach
# Delete all local branches to not have to merge them all
for branch in $(git for-each-ref --format="%(refname:strip=2)" refs/heads); do
git branch -D $branch
done
# Update from remote
git fetch --force --all --tags --prune --prune-tags
else
git clone $REPO $REPO_LOCATION;
cd $REPO_LOCATION;
git clone "$REPO" "$REPO_LOCATION";
cd "$REPO_LOCATION";
fi

# Checkout the correct branch
git checkout $BRANCH
git checkout "$BRANCH"

# Exit the repo
cd -
Expand Down