当它说 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
What does it mean when it says a git step is "1 ahead"
提问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
。这究竟是什么意思?前面是什么?
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 push
to your remote branch again to get rid of the 2 ahead
so to speak.
基本上,您需要push
再次访问远程分支以摆脱可以2 ahead
这么说的问题。
The master (the one on the top) is your local tracking branch, and origin/master
is a remote tracking branch that records the status of the remote repository from your last push
, pull
, or fetch
. origin
refers to your remote repository and master
is the current branch (also default) for that repository.
主设备(一个在顶部)是当地的跟踪分支,origin/master
是一个远程跟踪分支,记录从你最后一次远程仓库的状态push
,pull
或fetch
。origin
指的是您的远程存储库,并且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 push
again.
所以本质上,它说你的分支 ( master
) 比远程主分支 ( origin/master
)领先两次提交,这就是为什么我说你需要push
再次提交。
When you do a git status
on 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/master
is two commits behind master
.
在这里你会看到origin/master
后面有两个提交master
。
You may use git push origin master
to push your master
branch to origin
.
您可以使用git push origin master
将您的master
分支推送到origin
.