1

I want to create a branch that has files totally unrelated to master but when i create branch it starts with files from master.

How can i create new branch that wouldn't pull files from master?

P.S. I can pull new branch, delete all files and add my unrelated files but is there better way?

Mike
  • 465
  • 5
  • 14
  • You need to think about what you are doing. If this new work is to never interact with master, then a new folder (if the work is still somehow related) or a new repository (if this new work is completely seperate) are two options that don't rely on orphan branches. – crashmstr May 10 '17 at 12:27
  • The linked "original question" suggests using `--orphan`. This doesn't really solve the problem of not wanting any common content (hence still needing to delete everything); rather it makes the (fairly reasonable) assumption that unrelated files should be in commits that don't reach back to `master` as their parent, and solves that related problem (which will make for more sensible logs, etc; so long as you don't mean for changes to the new files to be synchronized in some way with changes to the old files...) That said... – Mark Adelsberger May 10 '17 at 13:35
  • @crashmstr - Thanks for comment. I was using new folders inside master but this looked messy for me. Is there any reason for not using orphan branches? – Mike May 10 '17 at 13:36
  • ...there isn't much of a solution to this problem, because it's a very strange problem. Can you elaborate on why you would want unrelated work trees to share a repo? – Mark Adelsberger May 10 '17 at 13:36
  • @Mike If the code is unrelated, is there any reason not to start a new repository? – crashmstr May 10 '17 at 13:43
  • @MarkAdelsberger - The case is that i'm prototyping an application and basically everything can change since i'm trying different frameworks for both backend and frontend plus VMs running those stacks. I share host folders with those VMs but want to have each stack on different host folder and different branch so i could pull it anywhere if needed. Hope it makes it a bit clearer. – Mike May 10 '17 at 13:49
  • @crashmstr - the code is related in this way that it is for one project (code can change, project stays same), and i'm using one repository as storage for code issues as well as business/ux issues. – Mike May 10 '17 at 13:53
  • Interesting use case. I assume one of these prototypes will "live on" to become the real project; but I suppose even then there could be an advantage to keeping a record of the other attempts. I'm on the fence about whether I would still use separate repos, but if I didn't, I would use a separate commit tree for each prototype (`--orphan` branches) and would use `git worktree` to allow checking out multiple prototypes/stacks using a single repo – Mark Adelsberger May 10 '17 at 14:01
  • (My previous comment assumes that there is *no* common starting point for these different prototypes. If there is, just commit the common stuff and create branches from there for each prototype I guess.) – Mark Adelsberger May 10 '17 at 14:03
  • @MarkAdelsberger - Thank You for comments, i will look more into `git worktree` as You suggested. – Mike May 10 '17 at 14:47

0 Answers0