GIT isn't fetching my new branch

戏子无情 提交于 2019-12-11 13:10:52

问题


I have created a new branch on my remote, so I would expect to do this:

$ git fetch && git checkout feature/name

However, I get this error:

error: pathspec 'feature/name' did not match any file(s) known to git.

When I run git fetch on its own, it doesn't return anything, I have also tried git fetch origin which does not work either.

git remote returns just the one remote called origin.

My config looks like this:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
[remote "origin"]
    url = removed as it is a private repo
    fetch = +refs/heads/staging:refs/remotes/origin/staging
[branch "staging"]
    remote = origin
    merge = refs/heads/staging

回答1:


As per Andrew C's comment. I changed the fetch line in my git config to this:

fetch=+refs/heads/*:refs/remotes/origin/*



回答2:


The fix is to correct your remote.origin.fetch parameter, e.g.

git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'

so all branches can be fetched. See: How to fetch all remote branches?




回答3:


If you are on GIt >1.9.X you have a default upstream with the value of simple.

If you want to get all the branches and tags you should use: git fetch --all --prune
--all will fetch all the branches and tags
--prune will delete all the deleted branches and tags

The flags will apply on your local repository.



来源:https://stackoverflow.com/questions/28663933/git-isnt-fetching-my-new-branch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!