How to copy files from branch to another using git?

I have a git repository with two branches: master and gh-pages . If I want to copy the foo file from master to gh-pages without merging them. Which command should I use? Thank you very much.

+42
git
Jul 02 '13 at 2:54 on
source share
3 answers

You can:

 git checkout gh-pages git checkout master foo git commit -m 'Add file foo to gh-pages.' 
+62
Jul 02 '13 at 3:05 on
source share

If you want to compare all the differences between the two branches: you can use git difftool master gh-pages or git difftool <SHA1 of gh-pages> .

If you want to get diff for a specific list of files, follow this :

 git diff master gh-pages -- path/to/file 
+2
Jul 02 '13 at 2:58
source share

How do I do this: when you commit, you have a choice of what to do and click. So copy only foo from master and then click it, then just merge it to github / bitbucket regardless of gh-pages

0
Jul 02 '13 at 2:57
source share



All Articles