Skip to content

Commit

Permalink
Fix problem with branch change
Browse files Browse the repository at this point in the history
  • Loading branch information
jmlord committed Mar 8, 2024
1 parent 3b5f374 commit 5c2e786
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions server-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ function assertSuccess {
echo "Updating server init script..."
if cd .server; then
# Check for a branch change
if [[ "$(git branch --show-current)" != $branch ]]; then
remoteFetch="+refs/heads/$branch:refs/remotes/origin/$branch"
if [[ "$(git config remote.origin.fetch)" != $remoteFetch ]]; then
echo "Switching to branch $branch..."

# Change branch restriction of shallow repo.
# We are not really changing branch but just allowing to checkout individual files from that other branch.
git config remote.origin.fetch "+refs/heads/$branch:refs/remotes/origin/$branch"
git config remote.origin.fetch "$remoteFetch"
# Delete all except .git, . and ..
ls -a | grep -Ev "^(\.git|\.|\.\.)$" | xargs rm -r
fi
Expand Down

0 comments on commit 5c2e786

Please sign in to comment.