假设我有一个项目已经工作了一段时间,然后我想从文件的一个子集重新开始,并保留这些文件的历史记录。
那么有没有一种方法可以手动将一个文件合并到新的空分支上?还是我需要合并所有文件,然后删除我不再需要的文件?
我正在尝试这个工作流程(但它并没有真正起作用)
$> git init
$> vi file1.c
$> git add file1.c
$> git commit -m 'first commit'
$> vi file2.c
$> git add file2.c
$> git commit -m 'added file2'
$> git log
commit 3788d18e62812d43f6b745f66fdab77081d79711
commit 3ab6959385c09fe2e254104a319a553ee58b198a
$> git checkout @{0}
Note: checking out '3ab6959385c09fe2e254104a319a553ee58b198a'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b new_branch_name
HEAD is now at 3ab6959... first commit
$> git branch -a
* (no branch)
master
$> git branch new_branch
$> git branch
* (no branch)
master
new_branch
$> git checkout new_branch
Switched to branch 'new_branch'
$> git mergetool master file1.c
merge tool candidates: opendiff kdiff3 tkdiff xxdiff meld tortoisemerge gvimdiff diffuse ecmerge p4merge araxis emerge vimdiff
master: file not found
Continue merging other unresolved paths (y/n) ? n
为什么我得到“主:找不到文件”?
合并应该是什么样子?
或者如何将特定提交中的特定文件合并到新分支?