- 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.
- 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.
Remote update was rejected by the target (Failure to Push to GitHub repository)
11 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(1 个)
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:
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Source Control 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!