CCheukKa
CCheukKa

Reputation: 9

Isolate repository subdirectory into a separate branch

How do I break a subdirectory from main and push it onto a new branch (preferrably without disturbing the history of main in the process)? I don't really care about the sub history.

Currently I have this:

-------main: ./foo
             ./dist/bar1
             ./dist/bar2

I want this:

-------main: ./foo

-------dist: ./bar1
             ./bar2

The ./dist/ folder is generated at runtime so I don't want that to be on main at all. My goal is to have this whole process done in a .yaml. dist will only get commit through this.

I tried cloning the dist branch to the folder acting as another unrelated repository but when I try to cd dist to run the git commands, the git context is stuck in main and it pushes the entire main root to dist.
I also tried doing git subtree but that is throwing an error: fatal: no new revisions were found.

Upvotes: 0

Views: 33

Answers (0)

Related Questions