Filter löschen
Filter löschen

Remote update was rejected by the target (Failure to Push to GitHub repository)

11 Ansichten (letzte 30 Tage)
Receiving the error message "The remote update was rejected by the target: refs/heads/main->refs/remotes/origin/main " when pushing my saved and committed changes to my remote github repository.
How do I track down the source of this error? I've had success using this functionality until now.
The change I was pushing was the addition of a new .mat file to the folder (which I copied in from elsewhere). Perhaps this is related to the error?

Antworten (1)

Siraj
Siraj am 2 Nov. 2023
Hi!
The error message "The remote update was rejected by the target: refs/heads/main->refs/remotes/origin/main" indicates that there is an issue preventing you from pushing your saved and committed changes to the remote repository. This error suggests that there might be a conflict between your local branch and the corresponding remote branch.
To troubleshoot this issue, you can follow these steps:
  1. Verify the branch names: Confirm that the local branch you are attempting to push from is named main and that the remote branch you want to push to is also named main. You can use commands like “git branch” to list local branches and “git branch -r” to list remote branches.
  2. Check for unmerged changes: Run “git status” to check for any uncommitted or unmerged changes in your local branch. If there are any, commit or stash them before proceeding with the push.
It also happens that you cannot push your changes directly because the remote repository has moved on. To continue, pull the latest changes from the remote repository into your local repository, and then push.
If this also doesn't seems to work then try the following.
In terminal:
git pull origin master --allow-unrelated-histories
In git GUI:
Click push to open the push window. Check "Force overwrite existing branch (may discard changes)". Then push.
Refer to the following link for instructions on setting up a remote repository in MATLAB, committing files, resolving conflicts, and pushing changes:
Hope this helps.

Kategorien

Mehr zu Source Control Integration finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by