当它说 git step 是“1 领先”时是什么意思

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22356961/
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-19 09:50:02  来源:igfitidea点击:

What does it mean when it says a git step is "1 ahead"

gitbitbucketatlassian-sourcetree

提问by CodyBugstein

I'm trying to learn git by playing around with it using SourceTree as as tool.

我正在尝试通过使用 SourceTree 作为工具来玩它来学习 git。

I added my local repository to a BitBucket repository and then made a couple of changes locally. I committed them, and then pushed them. I then logged onto BitBucket and manually changed a portion of the document (item "Added 4"). Then I went back to my local copy and changed it again and committed it. When I tried to push it, it told me I first had to pull and merge. So I did.

我将我的本地存储库添加到 BitBucket 存储库,然后在本地进行了一些更改。我犯了他们,然后推动了他们。然后我登录到 BitBucket 并手动更改了文档的一部分(项目“添加 4”)。然后我回到我的本地副本并再次更改并提交。当我试图推动它时,它告诉我我首先必须拉动并合并。所以我做了。

Then I pushed again. It worked.

然后我又推了一把。有效。

Now, the master (the top one. Why are there two?) carries a caption saying 2 ahead. What does this mean exactly? What is it ahead of?

现在,主人(最上面的一个。为什么有两个?)带有一个标题说2 ahead。这究竟是什么意思?前面是什么?

Git - SourceTree screenshot

Git - SourceTree 截图

UPDATE

更新

git status gives me:

git status 给了我:

JustMe@IMRAY ~/Projects/BlaBlaUser/gitPractice (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
  (use "git push" to publish your local commits)

nothing to commit, working directory clean

回答by gravetii

Basically, you need to pushto your remote branch again to get rid of the 2 aheadso to speak.

基本上,您需要push再次访问远程分支以摆脱可以2 ahead这么说的问题。

The master (the one on the top) is your local tracking branch, and origin/masteris a remote tracking branch that records the status of the remote repository from your last push, pull, or fetch. originrefers to your remote repository and masteris the current branch (also default) for that repository.

主设备(一个在顶部)是当地的跟踪分支,origin/master是一个远程跟踪分支,记录从你最后一次远程仓库的状态pushpullfetchorigin指的是您的远程存储库,并且master是该存储库的当前分支(也是默认分支)。

So in essence, it says that your branch (master) is ahead of the remote master branch (origin/master) by two commits, and that is why I say that you need to pushagain.

所以本质上,它说你的分支 ( master) 比远程主分支 ( origin/master)领先两次提交,这就是为什么我说你需要push再次提交。

When you do a git statuson your local, it should give you more clue about what is to be done.

当您git status在本地执行 a时,它应该为您提供有关要做什么的更多线索。

回答by Drew Noakes

It means that you have local commits that have not yet been pushed to that remote.

这意味着您有尚未推送到远程的本地提交。

For example:

例如:

* (master) Fix bar
* Fix foo
* (origin/master) Add bar
* Add foo

(newer commits are at the top)

(较新的提交位于顶部)

Here you see that origin/masteris two commits behind master.

在这里你会看到origin/master后面有两个提交master

You may use git push origin masterto push your masterbranch to origin.

您可以使用git push origin master将您的master分支推送到origin.