简体   繁体   English

源树推送:提示:更新被拒绝,因为当前分支的尖端落后

[英]Source Tree Push : hint: Updates were rejected because the tip of your current branch is behind

I am trying to push my application with Source Tree.我正在尝试使用 Source Tree 推送我的应用程序。

I reverted the application (locally) to an old version, made some changes and now I want to push again, but I'm getting this error:我将应用程序(本地)恢复到旧版本,进行了一些更改,现在我想再次推送,但出现此错误:

git -c diff.mnemonicprefix=false -c core.quotepath=false push -v --tags --set-upstream origin dev:dev
Pushing to https://user@bitbucket.org/hykaruz/assist-ponto.git
To https://user@bitbucket.org/hykaruz/project.git
 ! [rejected]        dev -> dev (non-fast-forward)



error: failed to push some refs to 'https:/User:bitbucket.org/hykaruz/Project.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.

PS.附注。 My version was too old, I had to download the last version then I can commit and push my application, so if you get the same problem check to see if there's an update.我的版本太旧了,我必须下载最后一个版本,然后我才能提交和推送我的应用程序,所以如果你遇到同样的问题,请检查是否有更新。

In my case for exact same error, I was not the only developer.在我遇到完全相同的错误的情况下,我不是唯一的开发人员。

So I went to commit & push my changes at same time, seen at bottom of the Commit dialog popup:所以我去提交并同时推送我的更改,在Commit对话框弹出的底部看到:

选中的选项:立即将更改推送到原点

...but I made the huge mistake of forgetting to hit the Fetch button to see if I have latest, which I did not. ...但我犯了一个巨大的错误,忘记点击“ Fetch按钮来查看我是否有最新的,而我没有。

The commit successfully executed, however not the push, but instead gives the same mentioned error;提交成功执行,但不是推送,而是给出了同样提到的错误; ...even though other developers didn't alter same files as me, I cannot pull latest as same error is presented. ...即使其他开发人员没有更改与我相同的文件,我也无法提取最新的文件,因为出现了相同的错误。

The GUI Solution图形用户界面解决方案

Most of the time I prefer sticking with Sourcetree's GUI (Graphical User Interface) .大多数时候我更喜欢坚持使用 Sourcetree 的GUI(图形用户界面) This solution might not be ideal, however this is what got things going again for me without worrying that I may lose my changes or compromise more recent updates from other developers.这个解决方案可能并不理想,但是这让我重新开始工作,而不必担心我可能会丢失我的更改或损害其他开发人员的最新更新。

STEP 1第 1 步

Right-click on the commit right before yours to undo your locally committed changes and select Reset current branch to this commit like so:右键单击您之前的提交以撤消本地提交的更改,然后选择将Reset current branch to this commit如下所示:

右键单击提交并选择的 Sourcetree 窗口:将当前分支重置为此提交

STEP 2第 2 步

Once all the loading spinners disappear and Sourcetree is done loading the previous commit, at the top-left of window, click on Pull button...一旦所有加载微调器消失并且 Sourcetree 完成加载前一个提交,在窗口的左上角,单击“ Pull按钮...

突出显示“拉”按钮的 Sourcetree 窗口

...then a dialog popup will appear, and click the OK button at bottom-right: ...然后将出现一个对话框弹出窗口,然后单击右下角的OK按钮:

突出显示“确定”按钮的 Sourcetree 窗口对话框弹出

STEP 3第 3 步

After pulling latest, if you do not get any errors, skip to STEP 4 (next step below).拉最新后,如果您没有收到任何错误,请跳到第4步(下面的下一步)。 Otherwise if you discover any merge conflicts at this point, like I did with my Web.config file:否则,如果您此时发现任何合并冲突,就像我对Web.config文件所做的那样:

显示错误提示的 Sourcetree 窗口:更新被拒绝,因为当前分支的尖端落后

...then click on the Stash button at the top, a dialog popup will appear and you will need to write a Descriptive-name-of-your-changes, then click the OK button: ...然后单击顶部的Stash按钮,将出现一个对话框弹出窗口,您需要编写一个 Descriptive-name-of-your-changes,然后单击OK按钮:

带有 Stash 按钮的 Sourcetree 窗口突出显示,弹出对话框显示输入以突出显示 OK 按钮命名您的 stash

...once Sourcetree is done stashing your altered file(s), repeat actions in STEP 2 (previous step above), and then your local files will have latest changes. ...一旦 Sourcetree 完成存储更改的文件,请重复步骤 2 中的操作(上面的上一步),然后您的本地文件将具有最新更改。 Now your changes can be reapplied by opening your STASHES seen at bottom of Sourcetree left column, use the arrow to expand your stashes, then right-click to choose Apply Stash 'Descriptive-name-of-your-changes' , and after select OK button in dialog popup that appears:现在可以通过打开在STASHES底部看到的 STASHES 来重新应用您的更改,使用箭头展开您的Apply Stash 'Descriptive-name-of-your-changes' ,然后右键单击以选择Apply Stash 'Descriptive-name-of-your-changes' ,然后选择OK出现的对话框弹出窗口中的按钮:

带有 Stashes 部分的 Sourcetree 窗口已展开并右键单击更改并突出显示 Apply Stash

Sourcetree 对话框弹出窗口要求您确认是否要将您的本地副本存储起来

IF you have any Merge Conflict(s) right now, go to your preferred text-editor, like Visual Studio Code, and in the affected files select the Accept Incoming Change link, then save:如果您现在有任何合并冲突,请转到您首选的文本编辑器,如 Visual Studio Code,并在受影响的文件中选择Accept Incoming Change链接,然后保存:

在此处输入图片说明

Then back to Sourcetree, click on the Commit button at top:然后回到 Sourcetree,点击顶部的Commit按钮:

在此处输入图片说明

then right-click on the conflicted file(s), and under Resolve Conflicts select the Mark Resolved option:然后右键单击冲突的文件,并在Resolve Conflicts选择Mark Resolved选项:

在此处输入图片说明

STEP 4第 4 步

Finally!!!终于!!! We are now able to commit our file(s), also checkmark the Push changes immediately to origin option before clicking the Commit button:我们现在可以提交我们的文件,并且在单击Commit按钮之前选中Push changes immediately to origin选项:

在此处输入图片说明

PS while writing this, a commit was submitted by another developer right before I got to commit, so had to pretty much repeat steps. PS 在写这篇文章时,另一个开发人员在我提交之前提交了一个提交,所以不得不重复步骤。

Because your commit history diverges from the upstream repository (you didn't just add more commits), git refuses to push the changes because you can lose work this way .因为您的提交历史与上游存储库不同(您不仅添加了更多提交),所以 git 拒绝推送更改,因为这样您可能会丢失工作

If you are sure you want to overwrite the upstream repository history with your own (eg, you are the only one pushing to that repository), you have to add -f to force the push.如果您确定要用自己的历史记录覆盖上游存储库历史记录(例如,您是唯一一个推送到该存储库的人),则必须添加-f以强制推送。

暂无
暂无

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

相关问题 更新被拒绝,因为您当前分支的提示落后 - 但为什么? - 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 filter-branch`之后无法推送到Heroku:更新被拒绝,因为当前分支的提示落后了 - Can't push to Heroku after a `git filter-branch`: Updates were rejected because the tip of your current branch is behind Git 更新被拒绝,因为您当前分支(主)的尖端在后面但是分支是最新的? - Git Updates were rejected because the tip of your current branch (main) is behind BUT branch is up to date? GitLab 更新被拒绝,因为您当前分支的尖端落后于其远程对应分支 - GitLab Updates were rejected because the 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 Github 错误“更新被拒绝,因为您当前分支的提示落后” - Github error "Updates were rejected because the tip of your current branch is behind" git:“更新被拒绝,因为您当前分支的尖端落后..”但是如何查看差异? - git: "Updates were rejected because the tip of your current branch is behind.." but how to see differences? 更新被拒绝,因为你当前分支的尖端落后于它的远程分支 - Updates were rejected because the tip of your current branch is behind its remote counterpart 如何解决 git 错误:“更新被拒绝,因为您当前分支的提示落后了” - How to resolve git error: "Updates were rejected because the tip of your current branch is behind"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM