Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AshishDhamalaAD/9b8e629421db06cd6306daca5c168ed9 to your computer and use it in GitHub Desktop.
Save AshishDhamalaAD/9b8e629421db06cd6306daca5c168ed9 to your computer and use it in GitHub Desktop.
How to pick specific files from one branch and add it to another branch

Let's say there are two branches: master and feature-one.

There are some files that you want in the master branch from the feature-one branch but not all the files. Let's say those files are:

app/Models/User.php
app/Controllers/UsersController.php

You can accomplish that by doing the following:

  • Checkout to the branch where you want to pull the changes. In our case, it's master branch.
git checkout master
  • Checkout to the branch from where you want those files with the path to the files. In our case, it's feature-one branch.
git checkout feature-one app/Models/User.php app/Controllers/UsersController.php

After executing this command, you will see those files in the master branch.

💥 BOOM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment