From c1b8f49c897a7f361eb2c9ac4551363e4096925b Mon Sep 17 00:00:00 2001 From: Toby Vincent Date: Thu, 1 Jul 2021 17:11:08 -0500 Subject: feat: created a script for splitting out a directory to its own repo --- docs/cheatsheet.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'docs/cheatsheet.md') diff --git a/docs/cheatsheet.md b/docs/cheatsheet.md index 01e7e43..e0a00e9 100644 --- a/docs/cheatsheet.md +++ b/docs/cheatsheet.md @@ -2,6 +2,7 @@ My personal cheat sheet of commands for various tools and workflows - [Git](#git) - [Split out subfolder into new repository](#split-out-subfolder-into-new-repository) + - [(Optional) Migrate original subdir to submodule](#optional-migrate-original-subdir-to-submodule) - [WSL2 Yubikey Setup](#wsl2-yubikey-setup) - [SSH Agent](#ssh-agent) - [In Windows](#in-windows) @@ -16,16 +17,17 @@ My personal cheat sheet of commands for various tools and workflows *Be sure you are inside the original repo* ```sh -cd +cd / ``` Set local variables for use ```sh -username=tobyvin-cs340 -subdir=src/Plotter +username="$(git config user.username)" +subdir="$(git rev-parse --show-prefix)" newrepo="$(basename $subdir)" -oldrepo="$(pwd)" +oldrepo="$(git rev-parse --show-toplevel)" +cd $oldrepo ``` Create a new branch containing only the sub-directory using `git subtree` @@ -45,8 +47,7 @@ git init && git pull $oldrepo $newrepo Copy over the git artifacts from original repo's root directory ```sh -cp $oldrepo/.gitignore ./ -cp $oldrepo/.gitattributes ./ +cp -rt ./ $oldrepo/.gitignore $oldrepo/.gitattributes $oldrepo/.vscode ``` Commit changes @@ -73,6 +74,8 @@ Push newly created repository to remote git push -u origin master ``` +### (Optional) Migrate original subdir to submodule + Switch back into the original repository ```sh -- cgit v1.2.3-70-g09d2