Merge pull request #45 from mike-rambil/devBranch

feat: expand toc-source.json with additional Git commands and descrip…
This commit is contained in:
Micheal Palliparambil
2025-07-10 21:47:26 -05:00
committed by GitHub
26 changed files with 261 additions and 0 deletions

View File

@@ -19,6 +19,12 @@ git apply changes.diff
```sh
git apply changes.diff
```
- **Show what would change if the diff were applied.**
```sh
git apply --stat changes.diff
```
#### Steps

View File

@@ -19,6 +19,12 @@ git am my-changes.patch
```sh
git am my-changes.patch
```
- **Apply a patch and add a Signed-off-by line.**
```sh
git am --signoff my-changes.patch
```
#### Steps

View File

@@ -17,6 +17,12 @@ git worktree list
```sh
git worktree list
```
- **List worktrees in a machine-readable format.**
```sh
git worktree list --porcelain
```
#### Steps

View File

@@ -19,6 +19,12 @@ git worktree add <path> <branch>
```sh
git worktree add ../feature-branch feature
```
- **Create a worktree for a hotfix branch.**
```sh
git worktree add ../hotfix hotfix-branch
```
#### Steps

View File

@@ -23,6 +23,18 @@ git format-patch HEAD~1
```sh
git format-patch origin/main..HEAD --stdout > my-changes.patch
```
- **Create patch files for the last two commits.**
```sh
git format-patch -2
```
- **Create patch files for all commits since main.**
```sh
git format-patch -2 origin/main..HEAD
```
#### Steps

View File

@@ -19,6 +19,12 @@ git diff > changes.diff
```sh
git diff > changes.diff
```
- **Create a diff file for the last commit.**
```sh
git diff HEAD~1 > last-commit.diff
```
#### Steps

View File

@@ -19,6 +19,12 @@ git fetch -p && git branch -vv | grep '\[origin/.*: gone\]' | awk '{print $1}' |
```sh
git fetch -p && git branch -vv | grep '\[origin/.*: gone\]' | awk '{print $1}' | xargs -r git branch -d
```
- **Delete only feature branches whose remote is gone.**
```sh
git fetch -p && git branch -vv | grep '\[origin/feature: gone\]' | awk '{print $1}' | xargs -r git branch -d
```
#### Steps

View File

@@ -23,6 +23,13 @@ git branch -vv | ForEach-Object { if ($_ -match '\[.*: gone\]') { $parts = $_.Tr
git fetch -p
git branch -vv | ForEach-Object { if ($_ -match '[.*: gone]') { $parts = $_.Trim() -split '\s+'; $branch = $parts[0]; if ($branch -ne '') { git branch -d $branch } } }
```
- **Delete only feature branches whose remote is gone.**
```sh
git fetch -p
git branch -vv | ForEach-Object { if ($_ -match '[origin/feature: gone]') { $parts = $_.Trim() -split 's+'; $branch = $parts[0]; if ($branch -ne '') { git branch -d $branch } } }
```
#### Steps

View File

@@ -48,6 +48,12 @@ git clean -f -d
```sh
git clean -i
```
- **Delete untracked and ignored files.**
```sh
git clean -f -x
```
#### Steps

View File

@@ -21,6 +21,12 @@ git clone --mirror https://github.com/example/repo.git
```sh
git clone --mirror https://github.com/example/repo.git
```
- **Mirror-clone a private repo using SSH.**
```sh
git clone --mirror git@github.com:org/repo.git
```
#### Steps

View File

@@ -19,6 +19,12 @@ git init --bare my-repo.git
```sh
git init --bare my-repo.git
```
- **Initialize a bare repo in a custom directory for server hosting.**
```sh
git init --bare /srv/git/project.git
```
#### Steps

View File

@@ -19,6 +19,12 @@ git maintenance start
```sh
git maintenance start
```
- **Run maintenance tasks every hour for more active repos.**
```sh
git maintenance start --schedule=hourly
```
#### Steps

View File

@@ -19,6 +19,12 @@ git replace abc123 def456
```sh
git replace abc123 def456
```
- **Graft a new parent onto a commit for testing history changes.**
```sh
git replace --graft HEAD~2 HEAD
```
#### Steps

View File

@@ -21,6 +21,12 @@ git request-pull <start> <url> <end>
```sh
git request-pull v1.0 https://github.com/example/repo.git v1.1
```
- **Request a pull for a feature branch based on main.**
```sh
git request-pull main https://github.com/example/repo.git feature-branch
```
#### Steps

View File

@@ -21,6 +21,12 @@ git push --force-with-lease
```sh
git push --force-with-lease
```
- **Force-push a specific branch with lease protection.**
```sh
git push --force-with-lease origin feature-branch
```
#### Steps

View File

@@ -29,6 +29,12 @@ git add path/to/file1.txt path/to/file2.txt
git commit -m "Pulled changes for file1.txt and file2.txt from commit e8ab7f64"
git push origin revert/productionOrder
```
- **Restore files using the newer 'git restore' command.**
```sh
git restore --source e8ab7f64fdfcc7bdaaed8d96c0ac26dce035663f path/to/file1.txt path/to/file2.txt
```
#### Steps

View File

@@ -19,6 +19,12 @@ git worktree remove <worktree-path>
```sh
git worktree remove ../feature-branch
```
- **Remove a hotfix worktree.**
```sh
git worktree remove ../hotfix
```
#### Steps

View File

@@ -19,6 +19,12 @@ git blame filename.txt
```sh
git blame filename.txt
```
- **Blame only lines 10 to 20 of a file.**
```sh
git blame -L 10,20 filename.txt
```
#### Steps

View File

@@ -17,6 +17,12 @@ git log --oneline -- filename.txt
```sh
git log --oneline -- filename.txt
```
- **Show commit history for a different file.**
```sh
git log --oneline -- path/to/anotherfile.js
```
#### Steps

View File

@@ -19,6 +19,12 @@ git log --pretty=format:"%h - %an, %ar : %s" -- filename.txt
```sh
git log --pretty=format:"%h - %an, %ar : %s" -- filename.txt
```
- **Show commit hash, short date, author, and message.**
```sh
git log --pretty=format:'%h | %ad | %an | %s' --date=short -- filename.txt
```
#### Steps

View File

@@ -19,6 +19,12 @@ git log -p -- filename.txt
```sh
git log -p -- filename.txt
```
- **Show the last two commits and their changes for a file.**
```sh
git log -p -2 -- filename.txt
```
#### Steps

View File

@@ -17,6 +17,12 @@
```sh
cd ../feature-branch
```
- **Switch to a hotfix worktree.**
```sh
cd ../hotfix
```
#### Steps

View File

@@ -19,6 +19,12 @@ git worktree add ../hotfix hotfix-branch
```sh
git worktree add ../hotfix hotfix-branch
```
- **Create a worktree for a bugfix branch.**
```sh
git worktree add ../bugfix bugfix-branch
```
#### Steps

View File

@@ -22,6 +22,12 @@ git branch -vv | grep -E '^\s*\S+\s+[^\[]+$'
```sh
git branch -vv | grep -E '^\s*\S+\s+[^\[]+$' | awk '{print $1}' | xargs git branch -D
```
- **List branches whose remote is gone.**
```sh
git branch -vv | grep 'gone'
```
#### Steps

View File

@@ -22,6 +22,12 @@ git branch -vv | Select-String -NotMatch "origin/"
```sh
git branch -vv | Select-String -NotMatch "origin/" | ForEach-Object { $branch = ($_ -split "\s+")[1]; git branch -D $branch }
```
- **List branches whose remote is gone.**
```sh
git branch -vv | Select-String 'gone'
```
#### Steps

View File

@@ -21,6 +21,10 @@
{
"code": "git maintenance start",
"description": "Enable background maintenance for your repository."
},
{
"code": "git maintenance start --schedule=hourly",
"description": "Run maintenance tasks every hour for more active repos."
}
],
"steps": ["Run `git maintenance start` in your repository."],
@@ -47,6 +51,10 @@
{
"code": "git request-pull v1.0 https://github.com/example/repo.git v1.1",
"description": "Generate a pull request message from v1.0 to v1.1."
},
{
"code": "git request-pull main https://github.com/example/repo.git feature-branch",
"description": "Request a pull for a feature branch based on main."
}
],
"steps": [
@@ -90,6 +98,10 @@
{
"code": "git fetch -p && git branch -vv | grep '\\[origin/.*: gone\\]' | awk '{print $1}' | xargs -r git branch -d",
"description": "Delete all local branches whose remote is gone."
},
{
"code": "git fetch -p && git branch -vv | grep '\\[origin/feature: gone\\]' | awk '{print $1}' | xargs -r git branch -d",
"description": "Delete only feature branches whose remote is gone."
}
],
"steps": [
@@ -119,6 +131,10 @@
{
"code": "git fetch -p\ngit branch -vv | ForEach-Object { if ($_ -match '[.*: gone]') { $parts = $_.Trim() -split '\\s+'; $branch = $parts[0]; if ($branch -ne '') { git branch -d $branch } } }",
"description": "Delete all local branches whose remote is gone."
},
{
"code": "git fetch -p\ngit branch -vv | ForEach-Object { if ($_ -match '[origin/feature: gone]') { $parts = $_.Trim() -split 's+'; $branch = $parts[0]; if ($branch -ne '') { git branch -d $branch } } }",
"description": "Delete only feature branches whose remote is gone."
}
],
"steps": [
@@ -150,6 +166,10 @@
{
"code": "git branch -vv | grep -E '^\\s*\\S+\\s+[^\\[]+$' | awk '{print $1}' | xargs git branch -D",
"description": "Delete local branches without remote tracking."
},
{
"code": "git branch -vv | grep 'gone'",
"description": "List branches whose remote is gone."
}
],
"steps": [
@@ -181,6 +201,10 @@
{
"code": "git branch -vv | Select-String -NotMatch \"origin/\" | ForEach-Object { $branch = ($_ -split \"\\s+\")[1]; git branch -D $branch }",
"description": "Delete local branches without remote tracking."
},
{
"code": "git branch -vv | Select-String 'gone'",
"description": "List branches whose remote is gone."
}
],
"steps": [
@@ -220,6 +244,10 @@
{
"code": "git init --bare my-repo.git",
"description": "Create a bare repository for collaboration."
},
{
"code": "git init --bare /srv/git/project.git",
"description": "Initialize a bare repo in a custom directory for server hosting."
}
],
"steps": [
@@ -238,6 +266,10 @@
{
"code": "git clone --mirror https://github.com/example/repo.git",
"description": "Create a full backup or migration of a repository."
},
{
"code": "git clone --mirror git@github.com:org/repo.git",
"description": "Mirror-clone a private repo using SSH."
}
],
"steps": [
@@ -267,6 +299,10 @@
{
"code": "git replace abc123 def456",
"description": "Temporarily replace commit abc123 with def456."
},
{
"code": "git replace --graft HEAD~2 HEAD",
"description": "Graft a new parent onto a commit for testing history changes."
}
],
"steps": [
@@ -288,6 +324,10 @@
{
"code": "git push --force-with-lease",
"description": "Safely force-push your changes."
},
{
"code": "git push --force-with-lease origin feature-branch",
"description": "Force-push a specific branch with lease protection."
}
],
"steps": [
@@ -327,6 +367,10 @@
{
"code": "git log --oneline -- filename.txt",
"description": "List all commits that modified `filename.txt`."
},
{
"code": "git log --oneline -- path/to/anotherfile.js",
"description": "Show commit history for a different file."
}
],
"steps": ["Lists all commits that modified `filename.txt`."],
@@ -346,6 +390,10 @@
{
"code": "git log -p -- filename.txt",
"description": "Show each commit and the actual changes made to `filename.txt`."
},
{
"code": "git log -p -2 -- filename.txt",
"description": "Show the last two commits and their changes for a file."
}
],
"steps": [
@@ -364,6 +412,10 @@
{
"code": "git log --pretty=format:\"%h - %an, %ar : %s\" -- filename.txt",
"description": "Display commit hash, author, relative date, and commit message."
},
{
"code": "git log --pretty=format:'%h | %ad | %an | %s' --date=short -- filename.txt",
"description": "Show commit hash, short date, author, and message."
}
],
"steps": [
@@ -381,6 +433,10 @@
{
"code": "git blame filename.txt",
"description": "Show the last commit that changed each line of the file."
},
{
"code": "git blame -L 10,20 filename.txt",
"description": "Blame only lines 10 to 20 of a file."
}
],
"steps": ["Shows the last commit that changed each line of the file."],
@@ -423,6 +479,10 @@
{
"code": "git clean -i",
"description": "Interactive mode for selective deletion."
},
{
"code": "git clean -f -x",
"description": "Delete untracked and ignored files."
}
],
"steps": [
@@ -462,6 +522,10 @@
{
"code": "git worktree list",
"description": "List all active worktrees."
},
{
"code": "git worktree list --porcelain",
"description": "List worktrees in a machine-readable format."
}
],
"steps": ["List all active worktrees."],
@@ -477,6 +541,10 @@
{
"code": "git worktree add ../feature-branch feature",
"description": "Create a new worktree for the feature branch."
},
{
"code": "git worktree add ../hotfix hotfix-branch",
"description": "Create a worktree for a hotfix branch."
}
],
"steps": ["Create a worktree linked to a specific branch."],
@@ -495,6 +563,10 @@
{
"code": "git worktree remove ../feature-branch",
"description": "Detach a worktree without deleting the files."
},
{
"code": "git worktree remove ../hotfix",
"description": "Remove a hotfix worktree."
}
],
"steps": ["Detach a worktree without deleting the files."],
@@ -513,6 +585,10 @@
{
"code": "cd ../feature-branch",
"description": "Switch to the worktree directory."
},
{
"code": "cd ../hotfix",
"description": "Switch to a hotfix worktree."
}
],
"steps": ["Simply cd into the worktree directory to switch."],
@@ -528,6 +604,10 @@
{
"code": "git worktree add ../hotfix hotfix-branch",
"description": "Quickly apply a fix on another branch without leaving your main branch."
},
{
"code": "git worktree add ../bugfix bugfix-branch",
"description": "Create a worktree for a bugfix branch."
}
],
"steps": [
@@ -574,6 +654,14 @@
{
"code": "git format-patch origin/main..HEAD --stdout > my-changes.patch",
"description": "Create a single patch file for all commits on top of main."
},
{
"code": "git format-patch -2",
"description": "Create patch files for the last two commits."
},
{
"code": "git format-patch -2 origin/main..HEAD",
"description": "Create patch files for all commits since main."
}
],
"steps": [
@@ -602,6 +690,10 @@
{
"code": "git am my-changes.patch",
"description": "Apply a patch file and preserve commit info."
},
{
"code": "git am --signoff my-changes.patch",
"description": "Apply a patch and add a Signed-off-by line."
}
],
"steps": [
@@ -619,6 +711,10 @@
{
"code": "git diff > changes.diff",
"description": "Create a diff file of uncommitted changes."
},
{
"code": "git diff HEAD~1 > last-commit.diff",
"description": "Create a diff file for the last commit."
}
],
"steps": [
@@ -645,6 +741,10 @@
{
"code": "git apply changes.diff",
"description": "Apply a diff file of uncommitted changes."
},
{
"code": "git apply --stat changes.diff",
"description": "Show what would change if the diff were applied."
}
],
"steps": [
@@ -678,6 +778,10 @@
{
"code": "git add path/to/file1.txt path/to/file2.txt\ngit commit -m \"Pulled changes for file1.txt and file2.txt from commit e8ab7f64\"\ngit push origin revert/productionOrder",
"description": "Stage, commit, and push the restored files to a new branch."
},
{
"code": "git restore --source e8ab7f64fdfcc7bdaaed8d96c0ac26dce035663f path/to/file1.txt path/to/file2.txt",
"description": "Restore files using the newer 'git restore' command."
}
],
"steps": [