Git:无法获得远程和本地/服务器相同 [英] Git: unable to get remote and local/server the same
问题描述
git status
返回:
On branch develop
Your branch is ahead of 'origin/develop' by 14 commits.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
我的目标是使gitlab.com和服务器上的git分支同步.当我看一下两者之间的区别时,它表示服务器远程位置的提交是我认为实际上在gitlab.com上的提交.
My goal is to get the git branch on gitlab.com and on the server synchronized. When I look at the difference between the two, the commits that it states that remote on the server is ahead, are commits I believe are actually there on gitlab.com.
我在服务器上执行了以下操作:
I did the following on the server:
-
git status
返回您的分支比'origin/develop'提前14次提交." -
git reset --soft HEAD~1
-
git status
现在返回分支是最新的,包含原始/开发.要提交的更改:",然后返回包含更改的列表. -
git reset --hard
-
git status
现在返回分支是最新的,包含了origin/develop.没有要提交的内容." -
git log
缺少最新提交,因此本质上不同意步骤5. -
git pull origin develop
这带来了各种变化(由于步骤5返回最新" ...,这怎么可能?). -
git status
返回原始消息在14个提交之前在'origin/develop'之前",而我又回到了开始的地方.
git status
returns "Your branch is ahead of 'origin/develop' by 14 commits."git reset --soft HEAD~1
git status
now returns "branch is up-to-date with origin/develop. Changes to be committed:" and then a list with changes.git reset --hard
git status
now returns "branch is up-to-date with origin/develop. Nothing to commit."git log
is missing the latest commits and therefore essentially disagrees with step 5.git pull origin develop
This pulls various changes (how is that possible since step 5 returns "up-to-date"...?).git status
returns the original message "ahead of 'origin/develop' by 14 commits" and I'm back where I started.
我不明白这一点.从gitlab提取后,服务器如何返回到gitlab.com的前面(步骤8)?我删除了服务器上的所有更改,然后执行了拉动操作.
I don't understand this. How can the server return to being ahead of gitlab.com (step 8) after pulling from gitlab...? I removed all changes on the server and just did a pull...
推荐答案
- git status返回您的分支比'origin/develop'提前14次提交."
这并不意味着您的分支位于远程(起源)的前面. origin/develop
是 local 分支.它是一个远程跟踪分支,但不会自动更新.更新它的方法是说git fetch
-您从不说过的话.
This does not mean that your branch is ahead of the remote (origin). origin/develop
is a local branch. It is a remote tracking branch, but it is not updated automatically. The way to update it is to say git fetch
— something that you never report having said.
- git reset --soft HEAD〜1
- git状态现在返回分支是最新的,包含原始/开发.要提交的更改:",然后返回包含更改的列表.
- git reset --hard
- git status现在返回分支是最新的,具有origin/develop.没有要提交的内容."
- git日志缺少最新提交,因此本质上不同意步骤5.
- git reset --soft HEAD~1
- git status now returns "branch is up-to-date with origin/develop. Changes to be committed:" and then a list with changes.
- git reset --hard
- git status now returns "branch is up-to-date with origin/develop. Nothing to commit."
- git log is missing the latest commits and therefore essentially disagrees with step 5.
我不知道你为什么要这么做.您从develop
砍掉了一堆提交.您为什么要故意la当地分支机构?
I don't know why you did any of that. You chopped off a bunch of commits from develop
. Why would you deliberately lame your local branch?
另外,您对6的观点是错误的:踩下develop
,导致它与origin/develop
一致,而origin/develop
仍然没有变化.他们绝对同意.
Also, you are wrong about 6: having lamed develop
, you have caused it to agree with origin/develop
, which is still sitting there unchanged. They are absolutely in agreement.
- git pull origin development这会拉动各种更改(由于步骤5返回最新",这是怎么可能的?).
这是可能的,因为一旦敲击develop
,遥控器就在您前面.因此,您从远程拉出,现在您的develop
从刚刚切断的远程那里获取提交.
It's possible because, once you have lamed develop
, the remote is ahead of you. So you pull from the remote, and now your develop
gets the commits from the remote that you just chopped off it.
- git status返回原始消息在14个提交之前'origin/develop'之前",而我又回到了开始的位置.
因为您仍然尚未通过说git fetch
来更新origin/develop
.
Because you still have not updated origin/develop
by saying git fetch
.
因此基本上,您已经绕了圈子,因为(a)您不知道origin/develop
是什么,以及(b)您一直不更新origin/develop
.更新它!说git fetch
,然后您将通过git status
发现实际情况.我怀疑您会发现自己完全是最新的,并且一切都很好.
So basically you've gone around in circles because (a) you don't know what origin/develop
is and (b) you keep not updating origin/develop
. Update it! Say git fetch
, and you will then discover through git status
what the actual situation is. I suspect that you will find that you are completely up to date and all is well.
这篇关于Git:无法获得远程和本地/服务器相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!