summaryrefslogtreecommitdiffstatshomepage
path: root/docs/cheatsheet.md
diff options
context:
space:
mode:
authorToby Vincent <tobyv13@gmail.com>2021-07-01 17:11:08 -0500
committerToby Vincent <tobyv13@gmail.com>2021-07-01 17:11:08 -0500
commitc1b8f49c897a7f361eb2c9ac4551363e4096925b (patch)
treeecf9a44fbbee456bf8cd047526d55ecbc19bed14 /docs/cheatsheet.md
parent7a659a5a2bce2957927bf4c36130fe282f5005f7 (diff)
feat: created a script for splitting out a directory to its own repo
Diffstat (limited to 'docs/cheatsheet.md')
-rw-r--r--docs/cheatsheet.md15
1 files changed, 9 insertions, 6 deletions
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 <orignal_repository>
+cd <orignal_repository>/<subdir-to-split>
```
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