2

My project failed to compile, so I unsuccessfully tried a variety of solutions over another 8 commits - including some changes I want to preserve.

So my master has some files from a variety of commits that I want to pull over to my "Last Known Good" branch. (Maybe I'll have to do a line diff tool to merge changes within a few files too.)

Best answers I've found on how to 'merge' selected files to another branch are at:

I'm thinking that GitLens must have a way to right click on a file from a (otherwise evil) commit and perform a 'git checkout --patch CommitName FilePath' to add that commit's version of the file to the current checked out branch where I can test & likely commit it in the future.

I want to semi-automate this in VS Code as I have a lot of files to review/pull over.

I'm fairly new to git and GitLens and uncertain about all the options/terminology. Is this possible?!

Vash Juan
  • 37
  • 8
  • 1
    Can you just cherry pick without committing? Then you can decide what to keep and what to drop. Also if you really messed up the things, I suggest you do it from scratch, not to resort to complex operations like copying pieces from here and there. – Lex Li Dec 26 '21 at 21:31
  • Thanks Lex Li, but I found another route (using GitLens or maybe Git Graph - or VSCode?!) features: 1) In VSCode's Source Code view, right click and select "Switch to Commit" on the branch/commit you want to pull changes (from other branches) into. For me it was "Last_Known_Good". 2) Then right-click on files in other commits and select "Apply Changes" to add that version of the file (with any current changes you wish) to the list of files to be staged for the next commit to the branch you selected in 1) above. Worked smoothly for me! – Vash Juan Dec 28 '21 at 17:48
  • Then post your own answer and accept it. – Lex Li Dec 28 '21 at 17:50

0 Answers0