Bird
0
0

After renaming a remote branch, your local tracking branch still points to the old name. How to fix this?

medium📝 Troubleshoot Q7 of 15
Git - Remote Repositories
After renaming a remote branch, your local tracking branch still points to the old name. How to fix this?
ARun git fetch --prune and then set upstream to new remote branch
BDelete local branch and recreate it
CRun git reset --hard
DNothing, tracking updates automatically
Step-by-Step Solution
Solution:
  1. Step 1: Remove stale remote references

    Running git fetch --prune cleans up old remote branch references.
  2. Step 2: Update local branch tracking

    After pruning, set the local branch to track the renamed remote branch with git branch -u origin/new-name.
  3. Final Answer:

    Run git fetch --prune and then set upstream to new remote branch -> Option A
  4. Quick Check:

    Prune stale refs then update tracking branch [OK]
Quick Trick: Use 'git fetch --prune' to clean old refs before resetting tracking [OK]
Common Mistakes:
  • Expecting tracking to update automatically
  • Using git reset --hard which resets files
  • Deleting local branch unnecessarily

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Git Quizzes