You know that a file is old in a branch so you want to get the new version from another. For that, we use git checkout command. For more information, click git checkout link.


Check current status


inanzzz@inanzzz:~/project$ git branch
* branch-one
branch-two
develop
inanzzz@inanzzz:~/project$ git status
On branch branch-one
nothing to commit, working directory clean

Copy file


File "file_one.txt" in "branch-one" is old so we will copy and replace it with a new version which is in "branch-two".


inanzzz@inanzzz:~/project$ git checkout branch-two file_one.txt
inanzzz@inanzzz:~/project$ git status
On branch branch-one
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

modified: file_one.txt