-2

I have 2 branches that are children of the dev branch, let's say dev/branchA and dev/branchB. I want to pick a single file from the last commit of dev/branchA and overwrite it in dev/branchB. The path and the filename are the same. How can i do it only using git?

  • Does this answer your question? [How to get just one file from another branch](https://stackoverflow.com/questions/2364147/how-to-get-just-one-file-from-another-branch) – Joe Jun 12 '20 at 13:47

1 Answers1

2

You can simply checkout the file from branchA:

git checkout branchB
git checkout branchA path/to/file

Or, since Git 2.23:

git restore --source branchB path/to/file
Maroun
  • 94,125
  • 30
  • 188
  • 241