Copy a file from one branch to another
From Logic Wiki
You have to commit changes in the current branch, so you have to switch first to the branch where you want to add and commit the file, check out the file from the other branch, and then commit it:
#initial check in of the file in branch B: git checkout B git add some-file.txt git commit -m "Added some file"
Now copy the file over to branch A:
git checkout A git checkout B some-file.txt git status # On branch A # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: some-file.txt #