Git checkout file from branch - How to get just one file from another branch

968    Asked by YajairaSatchell in Data Science , Asked on Jul 14, 2021
I am using git and working on the master branch. This branch has a file called app.js.

I have an experiment branch in which I made a bunch of changes and tons of commits. Now I want to bring all the changes done only to app.js from experiment to master branch.

How do I do that?

Once again I do not want a merge. I just want to bring all the changes in app.js from experiment branch to master branch.
Answered by Arun Singh

To solve checkout file from another branch

Say, you are on the 'master' branch. Now you want to get 'app_new.js' file from 'new-feature' branch.

Use the following command:

    $ git checkout new-feature path/to/app_new.js


Your Answer

Interviews

Parent Categories