0

The way I understand it, I cannot pull a certain directory in a branch on GitHub, but I would essentially have to make another branch and pull that whole branch.

So, for example:

Top
----Branch1
----Branch2
----Branch3

If I wanted to update the Branch2 folder, would I be better off assigning those sort of changes to a branch?

I would just like to confirm this before I go ahead and make these branches. Thank you.

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
CoF
  • 1
  • 1
    I'm having trouble understanding your question, and that might indicate some confusion over the concepts. Why do you have folders named after branches? A branch is independent from folders. A branch is state of your code, which allows it to be modified without affecting other branches until you choose to merge your commits into them. You typically wouldn't use branches that each have different, disconnected pieces of code in them (e.g., different folders), except in advanced scenarios. Can you clarify what you're trying to do? – Jeremy Caney Sep 15 '21 at 18:03
  • Thanks for your response Jeremy and sorry for the confusion. I have many bash scripts each with their own menu system. Rather than pull each and every script I would just like to pull a certain directory related to a menu. So a directory would be pulled and updated once a certain script was ran. Does this make sense? – CoF Sep 18 '21 at 18:02
  • Aha, that makes sense. In that case, you _could_ have a set of disconnected (or “orphaned”) branches, each with a single folder. But it’s worth noting that your fundamental assumption that you can’t clone or pull a single folder is outdated. This is possible with what’s known as a _sparse checkout_. There are some good threads on this on Stack Overflow, such as [How do I clone a subdirectory only of a Git repository?](https://stackoverflow.com/q/600079/3025856); I specifically like the explanation in [@Cito Santilli’s 2018 answer](https://stackoverflow.com/a/52269934/3025856). Does that help? – Jeremy Caney Sep 18 '21 at 21:27
  • @JeremyCaney this looks brilliant and is exactly what I've been looking for! You've been a great help and thank you so much for taking the time to help me out. Wish you all the best. – CoF Sep 18 '21 at 21:51

0 Answers0