Sometimes, you changed some files in a feature branch for new feature and your teammate also starts to dev another feature before your feature is merged into master branch. Unfortunately, your teammate new to use some functions which is created in your feature branch. The feature which you are developing has not finished yet, so you can't merge it into master. We just need to merge specific files from feature to master.
For example, we have a branch called Feature. In that branch, we have a file called helper. We want to merge the helper file from Feature to Master to start another feature.
We need 2 following steps:
1.Checkout helper file to current working tree.
In git we can checkout a specific files from specific branch like the following:git checkout <branch> <paths>
So , for example, we can get helper file which is in app/helper/application_helper.rb
git checkout feature app/helper/application_helper.rb