Sunday, 7 April 2013

How to checkout other branch exact files in git

Here i am going to explain you, how to checkout other branch particular file in your working tree or current branch. Just assume your current working directory is "future"(git branch name is future).
You have one more branch called "master". Suppose if you want to checkout particular file from master branch into your future branch. Then do the following command it will work out well.

Lets move to your current branch, here "future" using following command

git checkout future

Now you shifted into "future" branch. Then do the following command, which we need exactly for our need(checkout particular file from master branch).

git checkout master -- file_1_name.txt,file_2_name.txt
(Just for examples file_1_name.txt and file_2_name.txt. According to your need you can change into your desired filenames list).

The above command will override your current branch(future branch) files you mentioned above command. So your local changes will be ignored.

Hopefully now you come to know how to checkout other branch files in your current branch!!. 

No comments :

Post a Comment