我是git的新手,我无法理解以下行为:
我有一个bitbucket repo,我在本地克隆,然后我在本地修改和提交,然后我推送到远程仓库.如果我进行隐式推送或"推送起源",则没有问题.如果我使用显式远程URL推送,我会收到状态消息"你的分支超前'origin/master'由1 commit'提供.
似乎git不能将显式地址识别为与origin相同,所以究竟是怎么回事.如果我做另一个隐式推送,它什么都不做,但它确实清除了所述消息.
这是一个示例会话:
baz@bhost:/more/coding/git-tests/ask1$ git --version
git version 1.7.2.5
baz@bhost:/more/coding/git-tests$ git clone https://shishani@bitbucket.org/shishani/dirasi.git ask1
Cloning into ask1...
Password:
remote: Counting objects: 24054, done.
remote: Compressing objects: 100% (6300/6300), done.
remote: Total 24054 (delta 17124), reused 24024 (delta 17106)
Receiving objects: 100% (24054/24054), 11.83 MiB | 251 KiB/s, done.
Resolving deltas: 100% (17124/17124), done.
baz@bhost:/more/coding/git-tests$ cd ask1
baz@bhost:/more/coding/git-tests/ask1$ jed setup.py
baz@bhost:/more/coding/git-tests/ask1$ git commit -a
[master a053f28] modified: setup.py
1 files changed, 1 insertions(+), 0 deletions(-)
baz@bhost:/more/coding/git-tests/ask1$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
nothing to commit (working directory clean)
baz@bhost:/more/coding/git-tests/ask1$ git remote show origin
Password:
* remote origin
Fetch URL: https://shishani@bitbucket.org/shishani/dirasi.git
Push URL: https://shishani@bitbucket.org/shishani/dirasi.git
HEAD branch: master
Remote branch:
master tracked
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (fast-forwardable)
baz@bhost:/more/coding/git-tests/ask1$ git push
Password:
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 314 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: bb/acl: shishani is allowed. accepted payload.
To https://shishani@bitbucket.org/shishani/dirasi.git
5e9ffd1..a053f28 master -> master
baz@bhost:/more/coding/git-tests/ask1$ git status
# On branch master
nothing to commit (working directory clean)
baz@bhost:/more/coding/git-tests/ask1$ jed setup.py
baz@bhost:/more/coding/git-tests/ask1$ git commit -a
[master 6d0e236] modified: setup.py
1 files changed, 1 insertions(+), 0 deletions(-)
baz@bhost:/more/coding/git-tests/ask1$ git push https://shishani@bitbucket.org/shishani/dirasi.git master
Password:
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 298 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: bb/acl: shishani is allowed. accepted payload.
To https://shishani@bitbucket.org/shishani/dirasi.git
a053f28..6d0e236 master -> master
baz@bhost:/more/coding/git-tests/ask1$ git status
# On branch master
**# Your branch is ahead of 'origin/master' by 1 commit.** <-- this does not reflect current state
#
nothing to commit (working directory clean)
baz@bhost:/more/coding/git-tests/ask1$ git push
Password:
Everything up-to-date
baz@bhost:/more/coding/git-tests/ask1$ git status
# On branch master
nothing to commit (working directory clean)
Run Code Online (Sandbox Code Playgroud)
Bor*_*lid 19
我相信你需要先把改变拉回来才能git意识到远程端已经更新了.您可以通过快速执行此操作git pull(或者,如您在示例中所示,a git push到跟踪的原点).
您也可以手动更改提交到哪些refs/remotes/origin点.
期望内容跟踪器识别存储库的任意远程同义词是不公平的; 想象一下,如果您有五个不同的URL,它们都是相同的服务器端存储库.当您推送回购A时,这是否意味着您的更改已提交到回购B(分支的来源)?git没办法知道.相反,它只在两种情况下更新远程头引用:拉动和推送到默认目标.
Sai*_*esh 19
当状态显示时Your branch is ahead of 'origin/master' by 1 commit,它确实意味着origin/master.也就是说,有一个名为指针origin/master在回购指向提交这是HEAD的是remote branch,和你master是领先的这次提交.
对于您的repo识别的所有遥控器<remote>/<branchname>,如果您拉/推/取,它会在仓库中创建一个指针.它只是一个指向提交的指针,如果你尝试checkout那个分支,你只会处于一个分离状态.
显然,当您执行git push或更新时,此指针会更新git push origin master,但显式推送到URL不会更新该指针,从而更新状态.
如果您只是在推送到网址时git fetch或git pull之后,状态消息也会在此情况下消失.
注意:如果您有多个遥控器,并且您将分支设置为跟踪其他远程分支,例如upstream master,您的状态消息将在这种情况下为Your branch is ahead of 'upstream/master' by 1 commit.因此,只有跟踪的远程分支才能进行比较.查看git config您当前分支正在跟踪的远程分支.
| 归档时间: |
|
| 查看次数: |
82482 次 |
| 最近记录: |