しばらく取り組んできたプロジェクトがあり、ファイルのサブセットからやり直して、それらのファイルの履歴を保持したいとします。
1 つのファイルを新しい空のブランチに手動でマージする方法はありますか? それとも、すべてのファイルをマージしてから、不要になったファイルを削除する必要がありますか?
私はこのワークフローを試していました(しかし、実際には機能しません)
$> 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
「マスター: ファイルが見つかりません」と表示されるのはなぜですか?
そのマージはどのように見えるべきですか?
または、特定のコミットで特定のファイルを新しいブランチにマージするにはどうすればよいですか?