0

My Git server has 2 branches:

Foo and Master

In Branch Foo:

Directory1

Directory2

In Branch Master:

Directory2

As you can see, in Branch Master, there is no Directory1.

Now, in directory 2 has changes in branch Foo

I am in branch Master, I would like to get changes from Foo* without **Directory1. How should I do?

Luc
  • 2,800
  • 2
  • 25
  • 46
  • 2
    Possible duplicate of [How to get just one file from another branch](http://stackoverflow.com/questions/2364147/how-to-get-just-one-file-from-another-branch) – Mad Physicist Nov 18 '15 at 06:45

1 Answers1

1

Git allows you to pull specific files and directories using checkout:

git checkout Foo -- Directory2

will pull just the Directory2 folder from Foo branch. -- tells git that everything that follows is a path spec.

If you want to do a true merge, follow one of the answers to this question: How do I merge a sub directory in git?

Community
  • 1
  • 1
Mad Physicist
  • 107,652
  • 25
  • 181
  • 264
  • But I ever pull source code from "Foo" Branch. It occurred: fatal: invalid reference: Foo – Luc Nov 18 '15 at 06:52
  • That contradicts the part where you ask "...how do I get changes from Foo...?" – Mad Physicist Nov 18 '15 at 06:54
  • Actually, I just pull source from master branch, and my Co-Worker push source to his branch and now I pull source from his branch. – Luc Nov 18 '15 at 06:56