简体   繁体   English

GitLab 更新被拒绝,因为您当前分支的尖端落后于其远程对应分支

[英]GitLab Updates were rejected because the tip of your current branch is behind its remote counterpart

i am using GitLab to store my code, at first, i pushed it on the branch master and nothing unexpectedly happened, then i think it would be my last commit for my project and then i deleted my whole project in my desktop.我正在使用 GitLab 存储我的代码,起初,我将它推送到分支 master 上,但没有任何意外发生,然后我认为这将是我对项目的最后一次提交,然后我在桌面上删除了整个项目。

Then i have idea to improve the last project that i have just completely deleted previously.然后我有想法改进我之前完全删除的最后一个项目。

Then, i create a new project do some git syntax to merge my current project to git repository of the project that i deleted然后,我创建一个新项目执行一些 git 语法将我当前的项目合并到我删除的项目的 git 存储库

feel so regret for this stupid thing that i have made :(为我所做的这件愚蠢的事情感到非常遗憾:(

firstly, i initialized git:首先,我初始化了 git:

git init

then, just want to make sure there are no branch-name, so i type:然后,只想确保没有分支名称,所以我输入:

git remote -v

of course, it clears, so i added my previous master branch-name git ssh "git@gitlab.com:Khangithub/react-practical-1.git" and it is called "origin"当然,它清除了,所以我添加了我以前的主分支名称 git ssh "git@gitlab.com:Khangithub/react-practical-1.git" 并且它被称为 "origin"

git remote add origin git@gitlab.com:Khangithub/react-practical-1.git
git add .
git commit -m "commit massage"
git push -u origin master

and it returns this error to me:并将此错误返回给我:

To https://gitlab.com/Khangithub/react-practical-1.git
! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://gitlab.com/Khangithub/react-practical-1.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Enumerating objects: 42, done.
Counting objects: 100% (42/42), done.
Delta compression using up to 8 threads
Compressing objects: 100% (38/38), done.
Writing objects: 100% (42/42), 221.29 KiB | 7.14 MiB/s, done.
Total 42 (delta 5), reused 0 (delta 0), pack-reused 0
remote: GitLab: You are not allowed to force push code to a protected branch on this project.
To https://gitlab.com/Khangithub/react-practical-1.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://gitlab.com/Khangithub/react-practical-1.git'

it asks me to git pull, so i tried:它要求我 git pull,所以我试过:

git pull

then然后

git pull -u origin master

even甚至

git pull -f origin master

even though i don't understand what i mean but i guess it want me to create a new branch in the git repository but i want to merge all my current project with code that i have pushed on from the project that i deleted :(即使我不明白我的意思,但我想它希望我在 git 存储库中创建一个新分支,但我想将我当前的所有项目与我从我删除的项目中推送的代码合并:(

I don't want to create a brand new gitLab project with the same purpose with one already had, thank you for taking time to help me out, it means a lot to me, hope you have a good day, thank you so much我不想创建一个与已有项目具有相同目的的全新 gitLab 项目,感谢您抽出时间帮助我,这对我来说意义重大,希望您有美好的一天,非常感谢

The problem your are having seems to be caused by the fact that you created a second local repository with git init instead of cloning the one you already have from gitlab.您遇到的问题似乎是由于您使用git init创建了第二个本地存储库而不是从 gitlab 克隆您已经拥有的存储库。 This creates a problem when pushing, because you now try to push changes from your local repository that shares no common history with the remote repository and gitlab is protecting you from overwriting all history in the remote repository that exists on gitlab.这会在推送时产生问题,因为您现在尝试从与远程存储库没有共同历史记录的本地存储库推送更改,而 gitlab 正在保护您免于覆盖 gitlab 上存在的远程存储库中的所有历史记录。

To get your project on gitlab updated with your current changes try the following:要使用当前更改更新 gitlab 上的项目,请尝试以下操作:

  • Clone your repository from gitlab into a local folder with git clone https://gitlab.com/Khangithub/react-practical-1.git yourLocalFolder使用git clone https://gitlab.com/Khangithub/react-practical-1.git yourLocalFolder将您的存储库从 gitlab 克隆到本地文件夹中
  • Copy the changes you made earlier into yourLocalFolder that you just cloned from gitlab.复制到你前面做的更改yourLocalFolder您刚刚从gitlab克隆。
  • Commit your local changes and push them to gitlab提交您的本地更改并将它们推送到 gitlab

This makes sure that there is a shared history between your local repository and your remote repository before pushing.这可确保在推送之前在本地存储库和远程存储库之间存在共享历史记录。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 更新被拒绝,因为你当前分支的尖端落后于它的远程分支 - Updates were rejected because the tip of your current branch is behind its remote counterpart GitHub更新被拒绝,因为当前分支的提示位于其远程对应的后面 - GitHub updates were rejected because the tip of current branch is behind its remote counterpart 如何修复Git中的问题:“更新被拒绝,因为推送的分支提示位于其远程对应的后面” - How to fix issue in Git: “Updates were rejected because a pushed branch tip is behind its remote counterpart” 更新被拒绝,因为您当前分支的提示落后 - 但为什么? - Updates were rejected because the tip of your current branch is behind - but why? 更新被拒绝,因为您当前分支的尖端在后面...不正确 - Updates were rejected, because the tip of your current branch is behind… Not true 如何解决git错误:重命名远程分支时“更新被拒绝,因为当前分支的提示落后” - How to resolve git error: “Updates were rejected because the tip of your current branch is behind” when renaming a remote branch git 推送 - 更新被拒绝,因为当前分支的尖端落后于远程对应 - git push - updates rejected because tip of current branch behind remote counterpart Git 更新被拒绝,因为您当前分支(主)的尖端在后面但是分支是最新的? - Git Updates were rejected because the tip of your current branch (main) is behind BUT branch is up to date? 推送到远程失败,因为“当前分支的尖端位于其远程对应部分之后” - Pushing to remote fails because “tip of your current branch is behind its remote counterpart” Gradle-release-plugin 更新被拒绝,因为您当前分支的尖端落后 - Gradle-release-plugin Updates were rejected because the tip of your current branch is behind
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM