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

3 ビュー (過去 30 日間)
Joshua Himmelstein
Joshua Himmelstein 2022 年 4 月 29 日
回答済み: Siraj 2023 年 11 月 2 日
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?

回答 (1 件)

Siraj
Siraj 2023 年 11 月 2 日
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.

カテゴリ

Help Center および File ExchangeSource Control Integration についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by