Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git add branch on one single directory?

Tags:

git

branch

github

I have a git repository on GitHub, with 3 different folders and only the master branch. How can i create a new branch on one single directory instead of all the three?

like image 926
Blackecho Avatar asked May 05 '15 13:05

Blackecho


1 Answers

You can't. Git operates on the entire repository, not on individual directories. You can:

  • Create a new branch, and on that branch only modify things in your target directory.
  • You could obviously follow william.eyidi's suggestion and delete the other directories, but this will make things difficult if you want to merge changes back into your master branch.
  • You could set up the specific directory as a git submodule with it's own history separate from the parent repository, but this is probably more complex than it's worth.
like image 187
larsks Avatar answered Oct 14 '22 15:10

larsks