When I started to use Git, one of the first things I learned about it is that Git does not store information as list of file-based changes (patches), but as a stream of snapshots. A commit is a snapshot of all the repository.
Consider we have two branches in a repository Branch_A and Branch_B. No mater the relation between them, it may be very simple of very complicated (merge with others branches...). Just represent them like this:
A <--- ... -- I <----- J <----- K Branch_A
M <------ N <----- O <----- P Branch_B
For some reasons, I want that the next commit of Branch_A be exactly the state (the snapshot) of the commit P in Branch_B.
Is there a git command to do this ?
I can't use a "normal" merge, because I don't want to resolv conflicts between P and K. I can't use a recursive merge with the option "theirs" because it will keep all the files in K that do not conflicts with P, even if they do not exist in P.
I can do it like this :
cd /path/to/myrepo;
git checkout Branch_B
cp -R * /path/to/save_branch_b_state
git checkout Branch_A
rm -rf *
cp -R /path/to/save_branch_b_state . (In fact, I copy everything but the .git directory)
git add *
git commit
But I imagine there is a git command to do this.