Git:一起向前和向后。怎么解决?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15677746/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 15:51:39  来源:igfitidea点击:

Git: Ahead and Behind together. How to solve?

gitproject-management

提问by gaussblurinc

I have a commit with 1 aheadand 6 behind.

我有一个与1 ahead和的提交6 behind

What should I do in this situation?

在这种情况下我该怎么办?

I think, that solution might be like this: git pushand after git pull

我认为,该解决方案可能是这样的: git push然后 git pull

But I think, it can solve only Behind.
Maybe I am wrong.

但我认为,它只能解决Behind.
也许我错了。

-------*------*-----*-----*-----B
        \
         \
          \
           *-------A

I make my part and change sdk.
Now I want to merge with B.

我做我的一部分并改变sdk。
现在我想与B.

回答by Nevik Rehnel

git pull(or rather, the git mergepart that pulldoes) will "solve" both 'ahead' and 'behind'.

git pull(或者更确切地说,做的git merge部分pull)将“解决”“前面”和“后面”。

branch is X commits behindmeans that there are X new (unmerged) commits on the branch which is being tracked by your current branch.

branch is X commits behind意味着在当前分支正在跟踪的分支上有 X 个新的(未合并的)提交。

branch is X commits aheadanalogously means that your branch has X new commits, which haven't been merged into the tracked branch yet.

类似地,分支是 X 次提交意味着您的分支有 X 次新提交,这些提交尚未合并到被跟踪的分支中。

Once you've pulled (thereby merging the remote changes into your local ones) and pushed (thereby publishing your changes and the merge to the remote), your own branch and the remote branch will point to the same commit, so neither is ahead or behind.

一旦您拉取(从而将远程更改合并到您的本地更改)并推送(从而将您的更改和合并发布到远程),您自己的分支和远程分支将指向相同的提交,因此既不领先也不在后面。