Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add files to another branch?

Tags:

git

For some reason I want to abandon my branch_A but I have some files just committed in that branch_A. I want to add them to branch_B. How can I do that?

like image 694
hidemyname Avatar asked Jul 22 '15 06:07

hidemyname


1 Answers

Switch on the branch B:

git checkout branch_B

Then, checkout the files you want to keep:

git checkout branch_A file1 file2 file3 [...]

At last, commit your changes

git commit -m "Backport changes from branch A for reasons"
like image 194
blue112 Avatar answered Sep 28 '22 09:09

blue112