Hello everyone!

We have been investing plenty of personal time and energy for many years to share our knowledge with you all. However, we now need your help to keep this blog running. All you have to do is just click one of the adverts on the site, otherwise it will sadly be taken down due to hosting etc. costs. Thank you.

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
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