If I have a commit history (that was cloned from a remote repository for example) that looks like the following:
A ---> B ---> C ---> D (master)
and I want to create a branch that looks like the following:
A ---> B ---> C ---> D (master)
\-> N ---> B' ---> C' ---> D' (branch)
That is, insert a commit called 'N' on the branch right after commit A then copy to this branch the commits B, C, and D. Let's say I use the following steps to create the branch 'branch':
create 'branch' -> make commit N -> find the hash of the tree blob of commit B using git cat-file -p <hash of commit B>
-> run the command: git commit-tree <hash of tree blob of B> -p <hash of commit N>
-> move 'branch' to point to B' -> repeat the last two steps for commits C and D
After adding commit N, is there a risk of using the git commit-tree
command as is done above to copy commits B, C, D to the branch? Will I loose any files, changes, etc from B, C, or D from doing so (especially if there were conflicts between B and N for example)? As you can see this is different from using cherry-pick in the sense that cherry-pick checks for conflicts between B and B', C and C', D and D' before cherry-picking while this approach does not check for any conflicts.