Thanks very much! it works for me Lei
On Mon, Dec 17, 2012 at 5:23 AM, Thomas Ferris Nicolaisen <tfn...@gmail.com> wrote: > On Monday, December 17, 2012 1:58:53 PM UTC+1, lei yang wrote: >> >> Hi expert, >> >> now I'm in the branch A, I want to copy some file from branch B to A >> >> any help? >> > > 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 > # > > -- > > --