git get a file from a branch into another branch

I have 3 branches

  • 1
  • 2
    • Code
    • Readme WANTED
  • 3
    • Code
    • Readme Replace

Version 3 has the correct code but the wrong Readme (or a worse version), but there is a file in Version 2

This is how to get only 1 file

Switch to the version you want to update

As I want to work/progress version 3, I do a

git checkout 3

Extract the File from V2

To extract the version 2 file - we 1st check we have everything correct.

git show 2:Readme


readme V2 bla bla bla

Great that is the correct file .

Now Output this file

Slightly modify the output to create a fule

git show 2:Readme > Readme

When you are happy this is better then

git add Readme



git checkout 3
git checkout 2 Readme

Also works well (not tried)