Problem to push changes to remote repository on GitHub

93 次查看(过去 30 天)
Dear Matlab community,
I'm a newcomer to source control using Git integration in Matlab R2021a. I was able to clone my remote repository locally and to commit changes to this local repository within the Matlab interface. However, I have an issue to authenticate my GitHub credentials in order to push those commits to the remote repository. In Matlab, I right-click to see the Source Control, select the Push button and then type in my Github username and password but I got an incorrect username/password message and I know these are correct for sure. I don't find this issue if I push directly the commits from the Git desktop application to the remote repository.
I would appreciate any help to be able to push the commits directly from Matlab.
Thank you in advance for your time.
Best,
Noelia
  1 个评论
Andrey
Andrey 2025-5-15
The issue you're facing with authentication when pushing from MATLAB is likely due to GitHub no longer supporting password authentication. Instead, GitHub now requires the use of Personal Access Tokens (PAT) for Git operations over HTTPS. So even if you enter the correct password, GitHub will reject it.Here's what you can do:
  1. Generate a Personal Access Token (PAT) on GitHub
  • Go to: https://github.com/settings/tokens
  • Create a new token with the necessary scopes (e.g., repo for repository access).
  • Copy the token — you'll use this instead of your GitHub password.
  1. Use the token in MATLAB when prompted for credentials
  • When MATLAB asks for your Git credentials during a push:
  • Enter your GitHub username as usual.
  • Paste your PAT in the password field.
  1. Alternatively, set up SSH authentication or use Git Credential Manager
  • You can configure SSH keys with GitHub or use the Git Credential Manager for more seamless authentication without manually entering credentials.
  1. Check the Git version used by MATLAB
  • Make sure MATLAB is using an up-to-date Git version that supports modern authentication protocols.
If you're looking to streamline and automate other tasks — such as meeting coordination or project communication — you might want to try Wellpin. Wellpin is a smart scheduling tool that helps teams reduce back-and-forth communication by letting others book meetings in your available time slots, automatically sending invitations and reminders. It’s especially helpful for developers, managers, and cross-functional teams.

请先登录,再进行评论。

回答(2 个)

Mohammad Ibrahim
Mohammad Ibrahim 2022-7-19
编辑:Mohammad Ibrahim 2022-7-19
Hi Noelia,
I have also faced similar type of problem. For resolving this, I have generated a Personal Access Token on GitHub following below link and use this access token instead of my github password when I pushed the changes. Hope that it will help you.

Garrett Mitchener
Garrett Mitchener 2025-2-12
I just ran into this with a student. We're using GitHub Classroom and GitHub Desktop, which added some complications.
Here's what I think happened. When the student cloned her repository from GitHub, the local repository was set up with two git remotes. One, "origin", pointed to the student's repository on GitHub. The other, "upstream", pointed to my instructor repository. The student's repository on GitHub is a fork of the instructor repository. I think MATLAB tries to push to all remotes and pull from all remotes when you click those menu items. Since the student does not have access to the instructor repository, MATLAB runs into an error when trying push and pull to the "upstream" remote, so it pops up a dialog box asking for a password even though that can't work.
GitHub Desktop also tries to push and pull to all remotes, even the one that the student doesn't have access to. It pops up a dialog box saying that the repository no longer exists, referring to the "upstream" remote. But the dialog box doesn't state which remote it's trying to access, so it took me forever to figure out what was wrong.
The solution was to open a terminal, change directory to the student's local repository, and use git remote remove upstream to get rid of the bad remote. The "origin" remote was left in place and had the correct URL.

类别

Help CenterFile Exchange 中查找有关 Source Control 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by