Git: Copy a file between branches

October 30, 2019 - Last updated: October 30, 2019

Let's assume we have a two branches (A, B), and we want to move the file test.xt from branch A to branch B.

git checkout B
git checkout A -- test.txt
git status
git commit -m "Copy file test.txt
git push