Picking a file from another branch

Suppose you are working on a branch and need a file from another branch. As an example, I've created a branch called feature and made some changes to the toc.txt file in that branch. Now we switch back to the master branch and we are going to bring the last version of toc.txt from the feature branch onto the master branch. To do so, we run

git restore --source=feature -- toc.txt

Git will grab that version of the file and place it in our working tree. We can now stage it and commit it to the master branch.

Picking a file from another branch 1