![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1808198/931448053d0e66393df60b28c16922ee.png)
Why do I get a pop-up saying "Unable to switch to a remote branch. You must switch to a tracking branch" when trying to change branches?
16 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 15 Nov 2024
Réponse apportée : MathWorks Support Team
le 15 Nov 2024
Why do I get a pop-up saying "Unable to switch to a remote branch. You must switch to a tracking branch" when trying to change branches in the MATLAB Source Control dialogue for branches?
Réponse acceptée
MathWorks Support Team
le 15 Nov 2024
This is expected behavior due to how Git works.
Note, that this is not an error message, but information. The resolution is to simply click on "Create and Switch":
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1808198/931448053d0e66393df60b28c16922ee.png)
The background is that the references of the remotes ("refs/origin/...") cannot be checked out for modification, even if this is all on the local repository. The "Create and switch" button will create a new branch (which is just a new reference) locally and specify that it should be associated with the remote branch.
This association gives git targets for the commands "push" and "pull". The equivalent on the git command line is:
git checkout -b <branch-name> -t <remote-name>/<branch-name>
See also this page on the Git documentation for the background:
If there is an error when switching branches, then you have modified files in your working directory. Commit or Stash your changes to continue.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Source Control dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!