Using Git in Matlab adds an undesired branch everytime I push to the Gitlab repo

13 views (last 30 days)
Windows OS, Matlab 2022b.
I have a repo i Gitlab. I clone in it in Matlab, creating a new project as suggested here:
I got no erros, but everytime I commit and push something to main in the repo, "Matlab" creates an undesired branch in Gitlab and, also, the commit has my local pc user name, and not my Git account name.
I have of course followed all the setup steps when I set up for the first time Git in Matlab:
What can I do?
thanks

Accepted Answer

Dinesh
Dinesh on 4 May 2023
Hi Marco,
The first step to figuring out what is going wrong is to check your Git configuration.
Open a new Terminal window in MATLAB and then type the following command in it to check your global Git configuration.
git config --global --list
Now, look for "user.name" and "user.email" settings. If they are incorrect, then you can update them by running the following commands.
git config --global user.name "Your name"
git config --global user.email "youremail@gmail.com"
Now, you have to ensure that you are working on the correct branch. To check that, you can use the following comand:
git branch
Make sure that you are in your project directory where git is initialized and the branch name is "main".
If the branch name is not main, then you can change the branch using the following command:
git checkout main
If all these steps are not an issue for you, then the way you are committing and pushing the changes might be where the problem lies. The following commands are what you are expected to do whenever you make some changes and you want to commit these changes and then push these changes to Gitlab.
git add .
git commit -m "commit message"
git push -u origin main
These steps should make sure that you are committing and pushing changes to the right branch.
  2 Comments
Marco
Marco on 4 May 2023
Hi Dinesh,
thanks for the quick reply.
After typing in : git config --global --list , I get the following:
core.longpaths=true credential.helper=manager
I am using the GUI integrated in Matlab, within a project to control Git. So, I guess, it has something to do with credential helper manager. Could it be?
Dinesh
Dinesh on 7 May 2023
@Marco you can still continue with the next steps to see if you can solve the issue.
First, you can configure the user name and email in the global config
git config --global user.name "Your name"
git config --global user.email "youremail@gmail.com"
Then you can continue to check for branches and see if solves the issue.
If it does not, then you can try to disable the credential help manager to see if solves the issue by using the following command:
git config --global --unset credential.helper
Please let me know if the issue still persists.

Sign in to comment.

More Answers (0)

Categories

Find more on Source Control in Help Center and File Exchange

Tags

Products


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!