我从分支中克隆了一个 Github 项目,比如 br1
git clone --branch br1 https://www.github.com/project/project /opt/project/
我想切换到分支 br2,就好像我从一开始就这样做了:
git clone --branch br2 https://www.github.com/project/project /opt/project/
我不希望所有分支都在本地,只需要我使用的分支,因为我在资源有限的 VPS 上。
我可以做这样的事情(第一行的伪代码)吗?
git fetch origin/br2
git branch -D br1
编辑:这是我的 .config
# cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = https://www.github.com/project/project
[branch "br1"]
remote = origin
merge = refs/heads/br1