2013-04-10 83 views
0

我有一個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 

正如你所看到的,第一的哈希承諾是不同的。什麼是最簡單的方法來實現我想要做的事情?

回答

2

在主,

git branch empty 8b4c9dbcb4c5c0f966780f8b2f7ba356e3480fca 

git checkout -b empty 8b4c9dbcb4c5c0f966780f8b2f7ba356e3480fca