I was working on one Git branch and I wanted a file (src/Gateway.php
) from another branch (sf/update-wp-cli-commands-40
).
To do this, I ran the command
git checkout sf/update-wp-cli-commands-40 -- src/Gateway.php
Which added src/Gateway.php
to my Git working directory. I was then able to add the file and commit it to my current branch.
From a Specific Commit
Instead of using a branch name (sf/update-wp-cli-commands-40
), you can use anything that can be used to point to a single commit (e.g. a tag or a commit hash).
git checkout 8ebb9bf -- src/Gateway.php
Leave a Reply