chore: auto-generate README.md from toc-source.json

This commit is contained in:
github-actions[bot]
2025-07-11 03:43:15 +00:00
parent 9c5f83bb4b
commit 658e620422
25 changed files with 118 additions and 59 deletions

View File

@@ -15,10 +15,12 @@ git apply changes.diff
#### Examples
- **Apply a diff file of uncommitted changes.**
git apply changes.diff
```sh
git apply changes.diff```
- **Show what would change if the diff were applied.**
git apply --stat changes.diff
```sh
git apply --stat changes.diff```
#### Steps

View File

@@ -15,10 +15,12 @@ git am my-changes.patch
#### Examples
- **Apply a patch file and preserve commit info.**
git am my-changes.patch
```sh
git am my-changes.patch```
- **Apply a patch and add a Signed-off-by line.**
git am --signoff my-changes.patch
```sh
git am --signoff my-changes.patch```
#### Steps

View File

@@ -13,10 +13,12 @@ git worktree list
#### Examples
- **List all active worktrees.**
git worktree list
```sh
git worktree list```
- **List worktrees in a machine-readable format.**
git worktree list --porcelain
```sh
git worktree list --porcelain```
#### Steps

View File

@@ -15,10 +15,12 @@ git worktree add <path> <branch>
#### Examples
- **Create a new worktree for the feature branch.**
git worktree add ../feature-branch feature
```sh
git worktree add ../feature-branch feature```
- **Create a worktree for a hotfix branch.**
git worktree add ../hotfix hotfix-branch
```sh
git worktree add ../hotfix hotfix-branch```
#### Steps

View File

@@ -13,16 +13,20 @@ git format-patch HEAD~1
#### Examples
- **Create a .patch file for the last commit.**
git format-patch HEAD~1
```sh
git format-patch HEAD~1```
- **Create a single patch file for all commits on top of main.**
git format-patch origin/main..HEAD --stdout > my-changes.patch
```sh
git format-patch origin/main..HEAD --stdout > my-changes.patch```
- **Create patch files for the last two commits.**
git format-patch -2
```sh
git format-patch -2```
- **Create patch files for all commits since main.**
git format-patch -2 origin/main..HEAD
```sh
git format-patch -2 origin/main..HEAD```
#### Steps

View File

@@ -15,10 +15,12 @@ git diff > changes.diff
#### Examples
- **Create a diff file of uncommitted changes.**
git diff > changes.diff
```sh
git diff > changes.diff```
- **Create a diff file for the last commit.**
git diff HEAD~1 > last-commit.diff
```sh
git diff HEAD~1 > last-commit.diff```
#### Steps

View File

@@ -17,10 +17,12 @@ git fetch -p && git branch -vv | grep '\[origin/.*: gone\]' | awk '{print $1}' |
#### Examples
- **Delete all local branches whose remote is gone.**
git fetch -p && git branch -vv | grep '\[origin/.*: gone\]' | awk '{print $1}' | xargs -r git branch -d
```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.**
git fetch -p && git branch -vv | grep '\[origin/feature: gone\]' | awk '{print $1}' | xargs -r git branch -d
```sh
git fetch -p && git branch -vv | grep '\[origin/feature: gone\]' | awk '{print $1}' | xargs -r git branch -d```
#### Steps

View File

@@ -20,12 +20,14 @@ git branch -vv | ForEach-Object { if ($_ -match '\[.*: gone\]') { $parts = $_.Tr
#### Examples
- **Delete all local branches whose remote is gone.**
```sh
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 } } }
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 } } }
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

@@ -26,19 +26,24 @@ git clean
#### Examples
- **Preview what will be deleted (dry run).**
git clean -n -d
```sh
git clean -n -d```
- **Delete all untracked files.**
git clean -f
```sh
git clean -f```
- **Delete all untracked files and directories.**
git clean -f -d
```sh
git clean -f -d```
- **Interactive mode for selective deletion.**
git clean -i
```sh
git clean -i```
- **Delete untracked and ignored files.**
git clean -f -x
```sh
git clean -f -x```
#### Steps

View File

@@ -17,10 +17,12 @@ git clone --mirror https://github.com/example/repo.git
#### Examples
- **Create a full backup or migration of a repository.**
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.**
git clone --mirror git@github.com:org/repo.git
```sh
git clone --mirror git@github.com:org/repo.git```
#### Steps

View File

@@ -15,10 +15,12 @@ git init --bare my-repo.git
#### Examples
- **Create a bare repository for collaboration.**
git init --bare my-repo.git
```sh
git init --bare my-repo.git```
- **Initialize a bare repo in a custom directory for server hosting.**
git init --bare /srv/git/project.git
```sh
git init --bare /srv/git/project.git```
#### Steps

View File

@@ -17,10 +17,12 @@ git maintenance start
#### Examples
- **Enable background maintenance for your repository.**
git maintenance start
```sh
git maintenance start```
- **Run maintenance tasks every hour for more active repos.**
git maintenance start --schedule=hourly
```sh
git maintenance start --schedule=hourly```
#### Steps

View File

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

View File

@@ -19,9 +19,10 @@ git request-pull <start> <url> <end>
#### Examples
- **Generates a summary like:**
```sh
```The following changes since commit 1234567... (main):
The following changes since commit 1234567... (main):
Some previous commit message
@@ -41,10 +42,12 @@ for you to fetch changes up to 89abcde... (feature-branch):
```
- **Generate a pull request message from v1.0 to v1.1.**
git request-pull v1.0 https://github.com/example/repo.git v1.1
```sh
git request-pull v1.0 https://github.com/example/repo.git v1.1```
- **Request a pull for a feature branch based on main.**
git request-pull main https://github.com/example/repo.git feature-branch
```sh
git request-pull main https://github.com/example/repo.git feature-branch```
#### Steps

View File

@@ -17,10 +17,12 @@ git push --force-with-lease
#### Examples
- **Safely force-push your changes.**
git push --force-with-lease
```sh
git push --force-with-lease```
- **Force-push a specific branch with lease protection.**
git push --force-with-lease origin feature-branch
```sh
git push --force-with-lease origin feature-branch```
#### Steps

View File

@@ -17,15 +17,18 @@ git checkout <commit-hash> -- <file1> <file2>
#### Examples
- **Restore file1.txt and file2.txt from the specified commit.**
git checkout e8ab7f64fdfcc7bdaaed8d96c0ac26dce035663f -- path/to/file1.txt path/to/file2.txt
```sh
git checkout e8ab7f64fdfcc7bdaaed8d96c0ac26dce035663f -- path/to/file1.txt path/to/file2.txt```
- **Stage, commit, and push the restored files to a new branch.**
```sh
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
git push origin revert/productionOrder```
- **Restore files using the newer 'git restore' command.**
git restore --source e8ab7f64fdfcc7bdaaed8d96c0ac26dce035663f path/to/file1.txt path/to/file2.txt
```sh
git restore --source e8ab7f64fdfcc7bdaaed8d96c0ac26dce035663f path/to/file1.txt path/to/file2.txt```
#### Steps

View File

@@ -15,10 +15,12 @@ git worktree remove <worktree-path>
#### Examples
- **Detach a worktree without deleting the files.**
git worktree remove ../feature-branch
```sh
git worktree remove ../feature-branch```
- **Remove a hotfix worktree.**
git worktree remove ../hotfix
```sh
git worktree remove ../hotfix```
#### Steps

View File

@@ -15,10 +15,12 @@ git blame filename.txt
#### Examples
- **Show the last commit that changed each line of the file.**
git blame filename.txt
```sh
git blame filename.txt```
- **Blame only lines 10 to 20 of a file.**
git blame -L 10,20 filename.txt
```sh
git blame -L 10,20 filename.txt```
#### Steps

View File

@@ -13,10 +13,12 @@ git log --oneline -- filename.txt
#### Examples
- **List all commits that modified `filename.txt`.**
git log --oneline -- filename.txt
```sh
git log --oneline -- filename.txt```
- **Show commit history for a different file.**
git log --oneline -- path/to/anotherfile.js
```sh
git log --oneline -- path/to/anotherfile.js```
#### Steps

View File

@@ -15,10 +15,12 @@ git log --pretty=format:"%h - %an, %ar : %s" -- filename.txt
#### Examples
- **Display commit hash, author, relative date, and commit message.**
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.**
git log --pretty=format:'%h | %ad | %an | %s' --date=short -- filename.txt
```sh
git log --pretty=format:'%h | %ad | %an | %s' --date=short -- filename.txt```
#### Steps

View File

@@ -15,10 +15,12 @@ git log -p -- filename.txt
#### Examples
- **Show each commit and the actual changes made to `filename.txt`.**
git log -p -- filename.txt
```sh
git log -p -- filename.txt```
- **Show the last two commits and their changes for a file.**
git log -p -2 -- filename.txt
```sh
git log -p -2 -- filename.txt```
#### Steps

View File

@@ -13,10 +13,12 @@
#### Examples
- **Switch to the worktree directory.**
cd ../feature-branch
```sh
cd ../feature-branch```
- **Switch to a hotfix worktree.**
cd ../hotfix
```sh
cd ../hotfix```
#### Steps

View File

@@ -15,10 +15,12 @@ git worktree add ../hotfix hotfix-branch
#### Examples
- **Quickly apply a fix on another branch without leaving your main branch.**
git worktree add ../hotfix hotfix-branch
```sh
git worktree add ../hotfix hotfix-branch```
- **Create a worktree for a bugfix branch.**
git worktree add ../bugfix bugfix-branch
```sh
git worktree add ../bugfix bugfix-branch```
#### Steps

View File

@@ -12,13 +12,16 @@
#### Examples
- **List local branches without a remote connection.**
git branch -vv | grep -E '^\s*\S+\s+[^\[]+$'
```sh
git branch -vv | grep -E '^\s*\S+\s+[^\[]+$'```
- **Delete local branches without remote tracking.**
git branch -vv | grep -E '^\s*\S+\s+[^\[]+$' | awk '{print $1}' | xargs git branch -D
```sh
git branch -vv | grep -E '^\s*\S+\s+[^\[]+$' | awk '{print $1}' | xargs git branch -D```
- **List branches whose remote is gone.**
git branch -vv | grep 'gone'
```sh
git branch -vv | grep 'gone'```
#### Steps

View File

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