我有一个带有master
分支的git存储库,我想在其中创建一个empty
分支,其中包含master
分支的第一个提交,具有相同的分支哈希(最后一点非常重要)。我尝试过采摘樱桃,但这并没有提供相同的哈希值:
$ git log # we are on master
commit bfe76c82dace725e84e09dfa472b4ccef91495c6
Author: Name <email>
Date: Wed Apr 10 15:40:45 2013 +0200
Made some changes to README
commit 8b4c9dbcb4c5c0f966780f8b2f7ba356e3480fca
Author: Name <email>
Date: Wed Apr 10 15:39:35 2013 +0200
Added README
$ git checkout --orphan empty
Switched to a new branch 'empty'
$ git rm --cached *
rm 'README.rst'
$ git clean -fxd
Removing README.rst
$ git log
fatal: bad default revision 'HEAD'
$ git cherry-pick 8b4c9dbcb4c5c0f966780f8b2f7ba356e3480fca
[empty (root-commit) 1556211] Added README
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 README.rst
$ git log
commit 1556211343e404861ba9f7ec627b6d6f216217e0
Author: Name <email>
Date: Wed Apr 10 15:39:35 2013 +0200
Added README
如您所见,第一次提交的哈希值不同。实现我想做的最简单的方法是什么?
答案 0 :(得分:2)
在主人身上,
git branch empty 8b4c9dbcb4c5c0f966780f8b2f7ba356e3480fca
或
git checkout -b empty 8b4c9dbcb4c5c0f966780f8b2f7ba356e3480fca