dev-resources.site
for different kinds of informations.
Copy changed files to another branch in Git
Published at
12/27/2024
Categories
git
Author
Tetsuya KIKUCHI
Categories
1 categories in total
git
open
git checkout <branch> -- path/to/file
By the above command, you can pickup files to copy to another branch.
For example,
- You've been coding on branch-A for a long time.
- You wanna open a PR from some files of them.
- Then, execute:
# Switch back to main
git checkout main
# Create and switch
git checkout -b branch-B
# Import subset files to branch-B
git checkout branch-A -- path/to/file
Featured ones: