I have a git repository that I am using and I’ve screwed up. I made a few patches to the source tree and then went on to do upgrades without committing the patches first. Then I committed the whole batch together as one. My intent was to be doing the upgrades on a separate branch, which I did create before the commit.
Now at this point I have two (relevant) branches master, which is still stable but needs patched. And I have new_auth_system which has two commits ahead of master. The first is full of patches I did yesterday and committed. The second has a few more patches and an incredibly large and obscure amount of deletions and additions across several files.
I’ve been trying to use git checkout to pull the specific files out of the commit and tack them onto a clone of master in an attempt to get things corrected but I keep getting “fatal: reference is not a tree”
How do I go about pulling specific files across commits and into another branch?
Thanks!
If your situation is:
I would recommand first:
(if you haven’t pushed
new_auth_systemalready)rebase --interactiveto split y1 into y1a (with only your patches) and y1b (updates), and y2 in y2a (more patches) and y2b (massive refactoring)git checkout new_auth_system git rebase -i y1^ x--x--x--x (master, need patch) \ y1a--y1b--y2a--y2b new_auth_system, with y1a containing only patches y1b containing only updates y2a containing only patches y2a containing refactoringrebase --interactiveto reorder ‘y’ commits (patches first, updates and refactoring second)git checkout new_auth_system git rebase -i y1a^ x--x--x--x (master, need patch) \ y1a--y2a--y1b--y2b new_auth_system, with patches first (y1a, y2a) updates and refactoring secondmaster:x--x--x--x------x' (master, with patches) \ / y1a--y2a--y1b--y2b new_auth_system, with patches first, updates and refactoring secondIt is better than trying to isolate some files from one branch to another: Git reasons in term of project (a collection of files under a common tree), not in term of individual files.