Blackecho Blackecho - 6 months ago 49
Git Question

Git add branch on one single directory?

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?

Answer Source

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.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download