Git: Copy a file between branches

October 30, 2019 - Last updated: April 26, 2021

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

Related posts