更新时获取的预期行为如下(imho):
$ git fetch -p
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 2), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From AAA
a061e40..2058467 develop -> origin/develop
这对我来说在项目A中起作用。从同一个git主机,同一个本地系统,不同项目(比如项目B)获取,git fetch
没有输出。我认为它在某个时间点发生了变化,但我无法弄清楚原因是什么。
项目B,git fetch
输出:
$ git checkout develop
Switched to branch 'develop'
Your branch is up-to-date with 'origin/develop'.
$ git fetch -pv
From BBB
= [up to date] develop -> origin/develop
$ git status
On branch develop
Your branch is behind 'origin/develop' by 2 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
项目A配置:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
precomposeunicode = true
[remote "origin"]
url = AAA
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[branch "develop"]
remote = origin
merge = refs/heads/develop
$ git branch -vv
* develop a061e40 [origin/develop: behind 1]
项目B配置:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
precomposeunicode = true
[remote "origin"]
url = BBB
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[branch "develop"]
remote = origin
merge = refs/heads/develop
$ git branch -vv
* develop 7d1afd6 [origin/develop: behind 2]
如何将项目B中git fetch
的行为更改回项目A中的行为?
答案 0 :(得分:1)
您可以使用.git\refs\remotes\origin\develop
检查当前的开发分支提交ID。
如果两个提交相同,那意味着您的本地开发分支是最新的。
如果两个提交不同,您可以使用git log --oneline --decorate --graph --all
检查develop
和origin/develop
是否指向相同的提交ID。或者您可以使用git branch -D develop
和git checkout develop
,然后对远程仓库进行更改,然后再次执行git fetch
。