Additional Branch Fixes
This commit is contained in:
parent
862cb5bb82
commit
3c4e674f17
@ -21,12 +21,17 @@ process_repo() {
|
|||||||
# Detect the default branch dynamically
|
# Detect the default branch dynamically
|
||||||
DEFAULT_BRANCH=$(git remote show origin | awk '/HEAD branch/ {print $NF}')
|
DEFAULT_BRANCH=$(git remote show origin | awk '/HEAD branch/ {print $NF}')
|
||||||
|
|
||||||
|
# Check if the branch exists locally, and if not, create and set upstream
|
||||||
|
if ! git show-ref --verify --quiet refs/heads/$DEFAULT_BRANCH; then
|
||||||
|
git checkout -b $DEFAULT_BRANCH origin/$DEFAULT_BRANCH
|
||||||
|
fi
|
||||||
|
|
||||||
# Check if an upstream is configured; if not, set it
|
# Check if an upstream is configured; if not, set it
|
||||||
if ! git rev-parse @{u} > /dev/null 2>&1; then
|
if ! git rev-parse --abbrev-ref --symbolic-full-name @{u} > /dev/null 2>&1; then
|
||||||
git branch --set-upstream-to=origin/$DEFAULT_BRANCH $DEFAULT_BRANCH
|
git branch --set-upstream-to=origin/$DEFAULT_BRANCH $DEFAULT_BRANCH
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Fetch the latest changes
|
# Fetch the latest changes from the correct branch
|
||||||
git fetch origin $DEFAULT_BRANCH > /dev/null 2>&1
|
git fetch origin $DEFAULT_BRANCH > /dev/null 2>&1
|
||||||
|
|
||||||
# Check if the local repository is behind the remote
|
# Check if the local repository is behind the remote
|
||||||
|
Loading…
x
Reference in New Issue
Block a user