Merge remote-tracking branch 'refs/remotes/origin/devBranch' into devBranch

This commit is contained in:
mikerambil
2025-07-10 22:54:48 -05:00
25 changed files with 120 additions and 124 deletions

View File

@@ -4,25 +4,22 @@
# Apply Diff File
![Category: Patch & Diff](https://img.shields.io/badge/Category-Patch%20%26%20Diff-blue)
#### Command
```sh
git apply changes.diff
```
#### Examples
- **Apply a diff file of uncommitted changes.**
- **Apply a diff file of uncommitted changes.**
```sh
git apply changes.diff```
- **Show what would change if the diff were applied.**
```sh
git apply changes.diff
```
- **Show what would change if the diff were applied.**
````sh
```sh
git apply --stat changes.diff```
@@ -35,4 +32,3 @@ git apply --stat changes.diff```
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: diff, apply, uncommitted_
````

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -15,13 +15,13 @@ git clone --mirror https://github.com/example/repo.git
```
#### Examples
- **Create a full backup or migration of a repository.**
- **Create a full backup or migration of a repository.**
```sh
```sh
git clone --mirror https://github.com/example/repo.git```
- **Mirror-clone a private repo using SSH.**
- **Mirror-clone a private repo using SSH.**
```sh
```sh
git clone --mirror git@github.com:org/repo.git```

View File

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

View File

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

View File

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

View File

@@ -17,9 +17,9 @@ git request-pull <start> <url> <end>
```
#### Examples
- **Generates a summary like:**
- **Generates a summary like:**
```sh
```sh
The following changes since commit 1234567... (main):
@@ -40,13 +40,13 @@ for you to fetch changes up to 89abcde... (feature-branch):
file2.js | 5 +++++
2 files changed, 15 insertions(+)
```
- **Generate a pull request message from v1.0 to v1.1.**
- **Generate a pull request message from v1.0 to v1.1.**
```sh
```sh
git request-pull v1.0 https://github.com/example/repo.git v1.1```
- **Request a pull for a feature branch based on main.**
- **Request a pull for a feature branch based on main.**
```sh
```sh
git request-pull main https://github.com/example/repo.git feature-branch```

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -11,13 +11,13 @@
`cd <worktree-path>`
#### Examples
- **Switch to the worktree directory.**
- **Switch to the worktree directory.**
```sh
```sh
cd ../feature-branch```
- **Switch to a hotfix worktree.**
- **Switch to a hotfix worktree.**
```sh
```sh
cd ../hotfix```

View File

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

View File

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

View File

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