Skip to content

Commit 50a5d3c

Browse files
authored
Merge pull request #5435 from thewtex/branch-main-rebase
BUG: Use --replace-all for branch.main.rebase config
2 parents c4cd3c5 + d0b8f9f commit 50a5d3c

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

Utilities/SetupForDevelopment.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Utilities/GitSetup/github-tips
3131

3232
# Rebase main by default
3333
git config rebase.stat true
34-
git config branch.main.rebase true
34+
git config --replace-all branch.main.rebase true
3535

3636
# Disable old Gerrit hooks
3737
hook=$(git config --get hooks.GerritId) &&
@@ -134,15 +134,32 @@ if git show-ref --verify --quiet refs/heads/master; then
134134
# Update the upstream tracking if it exists
135135
if git config --get branch.master.remote > /dev/null 2>&1; then
136136
remote_name=$(git config --get branch.master.remote)
137+
merge_ref=$(git config --get branch.master.merge 2>/dev/null || true)
138+
139+
# Set up the main branch configuration
137140
git config branch.main.remote "$remote_name"
138141
git config branch.main.merge refs/heads/main
142+
143+
# Clean up old master branch configuration
139144
git config --unset branch.master.remote 2>/dev/null || true
140145
git config --unset branch.master.merge 2>/dev/null || true
141146

142147
echo "Updated upstream tracking to $remote_name/main"
143148
echo "Note: You may need to update the default branch on your remote repository."
144149
fi
145150

151+
# Ensure main branch merge configuration is set to main
152+
git config branch.main.merge refs/heads/main 2>/dev/null || true
153+
154+
# Update remote fetch configurations to use main instead of master
155+
for remote in $(git remote); do
156+
fetch_config=$(git config --get remote.$remote.fetch 2>/dev/null || true)
157+
if [[ "$fetch_config" == *"refs/heads/master:refs/remotes/$remote/master"* ]]; then
158+
echo "Updating $remote remote fetch configuration from master to main..."
159+
git config remote.$remote.fetch "+refs/heads/main:refs/remotes/$remote/main"
160+
fi
161+
done
162+
146163
# Switch back to the original branch if it wasn't master
147164
if test "$current_branch" != "master" && test "$current_branch" != ""; then
148165
echo "Switching back to '$current_branch' branch..."

0 commit comments

Comments
 (0)