Can git permanently ignore a remote branch?

删除回忆录丶 提交于 2019-11-28 01:47:56
Ondrej Peterka

You can modify the .gitconfig, so it tells git to fetch only what you just want:

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

Also, you can create an alias for the fetch which fetches what you want:

 git fetch origin +refs/heads/mybranch:refs/remotes/origin/mybranch

The creation of an alias is as simple as adding the new alias in .gitconfig:

 [alias]
   myfetch= git fetch origin +refs/heads/mybranch:refs/remotes/origin/mybranch

UPDATE:

You can specify more branches of course:

 git fetch origin +refs/heads/master:refs/remotes/origin/master +refs/heads/develop:refs/remotes/origin/develop

I just hit the same problem. I was interested in one branch from 'bob', but he had many branches cluttering up my git branch -a output.

I did this:

rm .git/refs/remotes/bob/{next,master,maint}

and the branches were gone. A git fetch might restore them though, but I don't intend to fetch from bob regularly.

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