我有一个裸存储库,用作我项目的中央存储.所有开发人员都git clone <repo>愿意与之分享.当他们进行克隆时,他们会检查主分支(除非他们这样做git clone -n)因为repo.git/HEAD包含ref: refs/heads/master,使其成为活动分支.
问题是,如何正确更改活动分支?我可以简单地直接破解repo.git/HEAD文件,但这看起来很讨厌,而且,哈哈.
我尝试git checkout <otherbranch>在repo .git目录中做,但是因为我不在工作树中而失败了.
我试过git update-ref HEAD refs/heads/otherbranch但是刚刚更新的refs/heads/master与refs/heads/otherbranch相同(好吧,我在虚拟存储库中做了那个,而不是我的生产!)
我试过git update-ref --no-deref HEAD refs/heads/otherbranch,这几乎奏效了.它更新了HEAD文件,但它将其设置为指向的提交的SHA1 refs/heads/otherbranch.
我正在使用git版本进行测试1.7.0.2.msysgit.0.
我猜测没有办法做到这一点git push,因为允许所有和各种更改你的默认分支似乎有点不安全(!),但肯定有一个更好的方法在repo .git目录中执行它比直接黑客HEAD文件.
我最近搞砸了我的git repo,想知道是否有任何补救措施.
我的设置是这样的:
Central repo on github.
Personal repo on github (which is a fork of Central)
+Central is setup as remote (upstream/master)
+Master branch (origin/master)
+Feature branch (origin/feature)
Run Code Online (Sandbox Code Playgroud)
我的工作流程是这样的:
Need to fix something in Central:
1. checkout Master
2. Make changes
3. Pull from upstream/master and merge
3. Commit, push to upstream/master
Need to work on a New Feature:
1. Checkout/Create Feature branch
2. Work work work
3. Pull from upstream/master and merge
4. Commit, push to upstream/master
Run Code Online (Sandbox Code Playgroud)
这样我在我的主人分支中总是有一个原始的中央状态. …