delet docs

This commit is contained in:
Micheal Palliparambilmikerambil@gmail.com
2025-07-26 02:16:02 -05:00
parent e185ed4448
commit e891a35aab
35 changed files with 0 additions and 1375 deletions
-36
View File
@@ -1,36 +0,0 @@
[⬅️ Back to Sharing Changes as Patch Files](./sharing-changes-as-patch-files.md)
[⬆️ Previous Step: Create Patch from Uncommitted Changes](./create-patch-from-uncommitted-changes.md)
# 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.**
```sh
git apply changes.diff
```
- **Show what would change if the diff were applied.**
```sh
git apply --stat changes.diff
```
#### Steps
1. Run '`git apply changes.diff' to apply the changes from a diff file`.
[➡️ See the Next Step: Patch vs Diff: Quick Reference](./patch-vs-diff-quick-reference.md)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: diff, apply, uncommitted_
@@ -1,36 +0,0 @@
[⬅️ Back to Sharing Changes as Patch Files](./sharing-changes-as-patch-files.md)
[⬆️ Previous Step: Create Patch from Last Commit(s)](./create-patch-from-last-commit-s.md)
# Apply Patch with Commit Metadata
![Category: Patch & Diff](https://img.shields.io/badge/Category-Patch%20%26%20Diff-blue)
#### Command
```sh
git am my-changes.patch
```
#### Examples
- **Apply a patch file and preserve commit info.**
```sh
git am my-changes.patch
```
- **Apply a patch and add a Signed-off-by line.**
```sh
git am --signoff my-changes.patch
```
#### Steps
1. Run '`git am my-changes.patch' to apply the patch and preserve commit messages, authorship, and timestamps`.
[➡️ See the Next Step: Create Patch from Uncommitted Changes](./create-patch-from-uncommitted-changes.md)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: patch, am, apply_
-34
View File
@@ -1,34 +0,0 @@
[⬅️ Back to How to Use git worktree Safely](./how-to-use-git-worktree-safely.md)
# Check Existing Worktrees
![Category: Worktree](https://img.shields.io/badge/Category-Worktree-blue)
#### Command
```sh
git worktree list
```
#### Examples
- **List all active worktrees.**
```sh
git worktree list
```
- **List worktrees in a machine-readable format.**
```sh
git worktree list --porcelain
```
#### Steps
1. List all active worktrees.
[➡️ See the Next Step: Create a New Worktree](./create-a-new-worktree.md)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: worktree, list_
-27
View File
@@ -1,27 +0,0 @@
[⬅️ Back to Table of Contents](../README.md#cleanup-branches-fast)
# Cleanup Branches Fast ⚡
![Category: Branch Management](https://img.shields.io/badge/Category-Branch%20Management-blue)
> Quickly view and clean up local branches using Bash or PowerShell, including removing branches whose remote is gone.
#### ProTips
> [!TIP]
> Run 'git fetch -p' before cleaning up branches to update remote info.
> [!TIP]
> Always double-check which branches will be deleted.
## Key Topics & Subcommands
- [Delete Local Branches Whose Remote is Gone (Bash)](./delete-local-branches-whose-remote-is-gone-bash.md): Delete all local branches whose remote counterpart has been deleted, using Bash.
- [Delete Local Branches Whose Remote is Gone (PowerShell)](./delete-local-branches-whose-remote-is-gone-powershell.md): Delete all local branches whose remote counterpart has been deleted, using PowerShell.
- [View and Clean Up Local Git Branches (Bash)](./view-and-clean-up-local-git-branches-bash.md): Scripts to view and clean up local branches using Bash.
- [View and Clean Up Local Git Branches (PowerShell)](./view-and-clean-up-local-git-branches-powershell.md): Scripts to view and clean up local branches using PowerShell.
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: branches, cleanup, fast, bash, powershell_
-40
View File
@@ -1,40 +0,0 @@
[⬅️ Back to How to Use git worktree Safely](./how-to-use-git-worktree-safely.md)
[⬆️ Previous Step: Check Existing Worktrees](./check-existing-worktrees.md)
# Create a New Worktree
![Category: Worktree](https://img.shields.io/badge/Category-Worktree-blue)
#### Command
```sh
git worktree add <path> <branch>
```
#### Examples
- **Create a new worktree for the feature branch.**
```sh
git worktree add ../feature-branch feature
```
- **Create a worktree for a hotfix branch.**
```sh
git worktree add ../hotfix hotfix-branch
```
#### Steps
1. Create a worktree linked to a specific branch.
#### Prerequisites
- The target path must not already be a git repository.
[➡️ See the Next Step: Remove a Worktree](./remove-a-worktree.md)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: worktree, add_
@@ -1,54 +0,0 @@
[⬅️ Back to Sharing Changes as Patch Files](./sharing-changes-as-patch-files.md)
# Create Patch from Last Commit(s)
![Category: Patch & Diff](https://img.shields.io/badge/Category-Patch%20%26%20Diff-blue)
#### Command
```sh
git format-patch HEAD~1
```
#### Examples
- **Create a .patch file for the last commit.**
```sh
git format-patch HEAD~1
```
- **Create a single patch file for all commits on top of main.**
```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
1. Run '`git format-patch HEAD~1' to create a patch for the last commit`.
2. Use '`git format-patch origin/main..HEAD --stdout > my-changes.patch' to create a single patch file for multiple commits`.
#### Warnings
- ⚠️ Patch files created this way include commit messages, authorship, and timestamps.
- ⚠️ Use 'git am' to apply these patches on another system.
#### Links
- [Official Docs](https://git-scm.com/docs/git-format-patch)
[➡️ See the Next Step: Apply Patch with Commit Metadata](./apply-patch-with-commit-metadata.md)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: patch, format-patch, committed_
@@ -1,44 +0,0 @@
[⬅️ Back to Sharing Changes as Patch Files](./sharing-changes-as-patch-files.md)
[⬆️ Previous Step: Apply Patch with Commit Metadata](./apply-patch-with-commit-metadata.md)
# Create Patch from Uncommitted Changes
![Category: Patch & Diff](https://img.shields.io/badge/Category-Patch%20%26%20Diff-blue)
#### Command
```sh
git diff > changes.diff
```
#### Examples
- **Create a diff file of uncommitted changes.**
```sh
git diff > changes.diff
```
- **Create a diff file for the last commit.**
```sh
git diff HEAD~1 > last-commit.diff
```
#### Steps
1. Run '`git diff > changes.diff' to save uncommitted changes to a file`.
#### Warnings
- ⚠️ This does NOT preserve commit metadata or history—just raw changes.
#### Links
- [Official Docs](https://git-scm.com/docs/git-diff)
[➡️ See the Next Step: Apply Diff File](./apply-diff-file.md)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: diff, uncommitted, snapshot_
@@ -1,54 +0,0 @@
[⬅️ Back to Cleanup Branches Fast ⚡](./cleanup-branches-fast.md)
# Delete Local Branches Whose Remote is Gone (Bash)
![Category: Branch Management](https://img.shields.io/badge/Category-Branch%20Management-blue)
> Delete all local branches whose remote counterpart has been deleted, using Bash.
This command fetches the latest remote info and deletes all local branches whose remote tracking branch no longer exists (marked as 'gone'). Useful for cleaning up after remote branch deletions.
#### Command
```sh
git fetch -p && git branch -vv | grep '\[origin/.*: gone\]' | awk '{print $1}' | xargs -r git branch -d
```
#### Examples
- **Delete all local branches whose remote is gone.**
```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
1. Fetch latest remote info: `git fetch -p`
2. List local branches whose remote is gone: `git branch -vv | grep '[origin/.*: gone`]'
3. Delete those branches: ... | awk '{print $1}' | xargs -r `git branch -d`
#### Warnings
- ⚠️ This will permanently delete local branches. Double-check before running.
- ⚠️ Make sure you have no unmerged work on these branches.
#### ProTips
> [!TIP]
> Use this after deleting branches on the remote to keep your local repo tidy.
> [!TIP]
> Add 'echo' before 'git branch -d' to preview what will be deleted.
[➡️ See the Next Step: Delete Local Branches Whose Remote is Gone (PowerShell)](./delete-local-branches-whose-remote-is-gone-powershell.md)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: branches, cleanup, gone, bash_
@@ -1,59 +0,0 @@
[⬅️ Back to Cleanup Branches Fast ⚡](./cleanup-branches-fast.md)
[⬆️ Previous Step: Delete Local Branches Whose Remote is Gone (Bash)](./delete-local-branches-whose-remote-is-gone-bash.md)
# Delete Local Branches Whose Remote is Gone (PowerShell)
![Category: Branch Management](https://img.shields.io/badge/Category-Branch%20Management-blue)
> Delete all local branches whose remote counterpart has been deleted, using PowerShell.
This script fetches the latest remote info and deletes all local branches whose remote tracking branch no longer exists (marked as 'gone'). Useful for cleaning up after remote branch deletions.
#### Command
```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 } } }
```
#### 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 } } }
```
- **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
1. Fetch latest remote info: `git fetch -p`
2. List local branches whose remote is gone: `git branch -vv | ForEach-Object { if ($_ -match '[.*: gone`]') ... }
3. Delete those branches inside the loop.
#### Warnings
- ⚠️ This will permanently delete local branches. Double-check before running.
- ⚠️ Make sure you have no unmerged work on these branches.
#### ProTips
> [!TIP]
> Great for Windows users to automate branch cleanup.
> [!TIP]
> Review the list before confirming deletion.
[➡️ See the Next Step: View and Clean Up Local Git Branches (Bash)](./view-and-clean-up-local-git-branches-bash.md)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: branches, cleanup, gone, powershell_
-21
View File
@@ -1,21 +0,0 @@
[⬅️ Back to How to Use git worktree Safely](./how-to-use-git-worktree-safely.md)
[⬆️ Previous Step: Use Worktrees for Temporary Fixes](./use-worktrees-for-temporary-fixes.md)
# Flags and Their Uses
#### Flags
- `add`: Creates a new worktree for an existing branch.
- `-b`: Creates a new worktree with a new branch.
- `list`: Lists all active worktrees.
- `remove`: Detaches a worktree from the repo without deleting files.
- `prune`: Cleans up stale worktree references after manual deletion.
- `move`: Moves a worktree to a different location.
[➡️ Continue to Next Topic: Sharing Changes as Patch Files](./sharing-changes-as-patch-files.md)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: worktree, flags_
@@ -1,78 +0,0 @@
[⬅️ Back to Table of Contents](../README.md#git-clean-remove-untracked-files-and-directories)
# Git Clean: Remove Untracked Files and Directories
![Category: Stashing and Cleaning](https://img.shields.io/badge/Category-Stashing%20and%20Cleaning-blue)
> Remove untracked files and directories from your repository.
`git clean` is a powerful command that helps remove untracked files and directories from your repository. It is particularly useful when you want to reset your working directory without affecting committed files.
#### Command
```sh
git clean
```
#### Flags
- `-n`: Shows what will be deleted without actually deleting anything.
- `-f`: Forces deletion of untracked files.
- `-d`: Deletes untracked directories.
- `-i`: Interactive mode to selectively delete files.
- `-x`: Removes ignored and untracked files.
- `-X`: Removes only ignored files.
#### Examples
- **Preview what will be deleted (dry run).**
```sh
git clean -n -d
```
- **Delete all untracked files.**
```sh
git clean -f
```
- **Delete all untracked files and directories.**
```sh
git clean -f -d
```
- **Interactive mode for selective deletion.**
```sh
git clean -i
```
- **Delete untracked and ignored files.**
```sh
git clean -f -x
```
#### Steps
1. Preview deletions: `git clean -n -d`
2. Delete untracked files: `git clean -f`
3. Delete untracked files and directories: `git clean -f -d`
4. Interactive deletion: `git clean -i`
5. Remove ignored and untracked files: `git clean -f -x`
6. Remove only ignored files: `git clean -f -X`
#### Prerequisites
- Make sure you have committed all important changes.
#### Warnings
- ⚠️ This will permanently delete files! Always use `-n` before `-f`.
- ⚠️ Be cautious with `-x` and `-X` as they remove ignored files, which might include config files.
#### Links
- [Official Docs](https://git-scm.com/docs/git-clean)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: clean, untracked, workspace_
-38
View File
@@ -1,38 +0,0 @@
[⬅️ Back to Git Command Reference (Full List)](./git-command-reference-full-list.md)
[⬆️ Previous Step: git init --bare](./git-init-bare.md)
# git clone --mirror <repository>
![Category: Repository Management](https://img.shields.io/badge/Category-Repository%20Management-blue)
> Clone a repository in mirror mode, including all refs and branches.
#### Command
```sh
git clone --mirror https://github.com/example/repo.git
```
#### Examples
- **Create a full backup or migration of a repository.**
```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
1. Run `git clone --mirror <repository>` to create a full backup or migration.
[➡️ Continue to Next Topic: Useful Rare Git Commands You Never Heard Of](./useful-rare-git-commands-you-never-heard-of.md)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: clone, mirror, backup_
@@ -1,18 +0,0 @@
[⬅️ Back to Table of Contents](../README.md#git-command-reference-full-list)
# Git Command Reference (Full List)
![Category: Reference](https://img.shields.io/badge/Category-Reference-blue)
> A comprehensive list of Git commands used in this project.
A comprehensive list of Git commands used in this project, formatted according to our standard.
## Key Topics & Subcommands
- [git init --bare](./git-init-bare.md): Initialize a bare repository, typically used for remote repositories.
- [git clone --mirror <repository>](./git-clone-mirror-repository.md): Clone a repository in mirror mode, including all refs and branches.
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: reference, all-commands_
-27
View File
@@ -1,27 +0,0 @@
[⬅️ Back to Table of Contents](../README.md#git-essentials-hidden-gems)
# Git Essentials & Hidden Gems
![Category: Miscellaneous](https://img.shields.io/badge/Category-Miscellaneous-blue)
> Start here to discover commands that can improve your workflow and understanding of Git.
A collection of practical, lesser-known, and foundational Git commands that are useful for all users. Start here to discover commands that can improve your workflow and understanding of Git.
#### ProTips
> [!TIP]
> Try these commands in a test repo before using them on important projects.
> [!TIP]
> Bookmark this section for quick reference to hidden gems.
## Key Topics & Subcommands
- [git maintenance start](./git-maintenance-start.md): Runs a cronJob in background for the specified repo for periodic maintenance.
- [git request-pull](./git-request-pull.md): Generate a request to pull changes into a repository.
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: misc, cleanup, advanced_
-36
View File
@@ -1,36 +0,0 @@
[⬅️ Back to Git Command Reference (Full List)](./git-command-reference-full-list.md)
# git init --bare
![Category: Repository Management](https://img.shields.io/badge/Category-Repository%20Management-blue)
> Initialize a bare repository, typically used for remote repositories.
#### Command
```sh
git init --bare my-repo.git
```
#### Examples
- **Create a bare repository for collaboration.**
```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
1. Run `git init --bare my-repo.git` to create a bare repository.
[➡️ See the Next Step: git clone --mirror <repository>](./git-clone-mirror-repository.md)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: init, bare, repository_
-57
View File
@@ -1,57 +0,0 @@
[⬅️ Back to Git Essentials & Hidden Gems](./git-essentials-hidden-gems.md)
# git maintenance start
![Category: Maintenance](https://img.shields.io/badge/Category-Maintenance-blue)
> Runs a cronJob in background for the specified repo for periodic maintenance.
`git maintenance start` enables background maintenance tasks for your Git repository. It sets up scheduled jobs (using your systems scheduler, like cron on Unix or Task Scheduler on Windows) to automatically run Git maintenance commands at regular intervals. This keeps your repository fast and healthy by running tasks like garbage collection, commit-graph optimization, and cleanup operations in the background, so you dont have to remember to do it manually.
#### Command
```sh
git maintenance start
```
#### Examples
- **Enable background maintenance for your repository.**
```sh
git maintenance start
```
- **Run maintenance tasks every hour for more active repos.**
```sh
git maintenance start --schedule=hourly
```
#### Steps
1. Run `git maintenance start` in your repository.
2. Optionally, use `--schedule=hourly` or `--schedule=daily` to control how often maintenance runs.
3. `Git will now automatically run tasks like garbage collection, pruning unreachable objects, and optimizing internal data structures in the background`.
4. You can stop background maintenance with `git maintenance stop` if needed.
#### ProTips
> [!TIP]
> Set up maintenance on large or long-lived repos to keep them fast and healthy.
> [!TIP]
> Use with cron or scheduled tasks for automation.
> [!TIP]
> If you notice Git getting slow, check if maintenance is enabled or run it manually.
#### Links
- [Official Docs](https://git-scm.com/docs/git-maintenance)
[➡️ See the Next Step: git request-pull](./git-request-pull.md)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: maintenance, automation_
@@ -1,36 +0,0 @@
[⬅️ Back to Useful Rare Git Commands You Never Heard Of](./useful-rare-git-commands-you-never-heard-of.md)
# git replace <old-commit> <new-commit>
![Category: History](https://img.shields.io/badge/Category-History-blue)
> Temporarily substitute one commit for another.
#### Command
```sh
git replace abc123 def456
```
#### Examples
- **Temporarily replace commit abc123 with 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
1. Run `git replace <old-commit> <new-commit>` to test or patch history.
[➡️ Continue to Next Topic: How to Use git push --force-with-lease Safely](./how-to-use-git-push-force-with-lease-safely.md)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: replace, history_
-82
View File
@@ -1,82 +0,0 @@
[⬅️ Back to Git Essentials & Hidden Gems](./git-essentials-hidden-gems.md)
[⬆️ Previous Step: git maintenance start](./git-maintenance-start.md)
# git request-pull
![Category: Collaboration](https://img.shields.io/badge/Category-Collaboration-blue)
> Generate a request to pull changes into a repository.
`git request-pull` generates a summary message describing the changes between two commits, which you can send to a project maintainer to request that they pull your changes. This is especially useful for email-based workflows or when collaborating outside of platforms like GitHub. The command outputs a message that includes a comparison summary, a list of commits, and their messages, making it easy for maintainers to review and apply your changes.
#### Command
```sh
git request-pull <start> <url> <end>
```
#### Examples
- **Generates a summary like:**
```sh
The following changes since commit 1234567... (main):
Some previous commit message
are available in the Git repository at:
https://github.com/example/repo.git feature-branch
for you to fetch changes up to 89abcde... (feature-branch):
New feature commit message
Another commit message
----------------------------------------------------------------
file1.txt | 10 ++++++++++
file2.js | 5 +++++
2 files changed, 15 insertions(+)
```
- **Generate a pull request message from v1.0 to 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.**
```sh
git request-pull main https://github.com/example/repo.git feature-branch
```
#### Steps
1. Identify the base commit or branch you want to compare from (e.g., main or v1.0).
2. Run `git request-pull <start> <url> <end>` to generate a pull request message.
3. Send the generated message to the project maintainer (e.g., via email or chat).
#### ProTips
> [!TIP]
> Use this command when collaborating via email or outside of web-based platforms.
> [!TIP]
> Include a clear start and end point for clarity.
> [!TIP]
> Review the generated message before sending to ensure it accurately describes your changes.
#### Links
- [Official Docs](https://git-scm.com/docs/git-request-pull)
[➡️ Continue to Next Topic: Cleanup Branches Fast ⚡](./cleanup-branches-fast.md)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: collaboration, pull-request_
@@ -1,51 +0,0 @@
[⬅️ Back to Table of Contents](../README.md#how-to-use-git-push-force-with-lease-safely)
# How to Use git push --force-with-lease Safely
![Category: Collaboration](https://img.shields.io/badge/Category-Collaboration-blue)
> Safely force-push to a branch without overwriting others' work.
Guide to using `git push --force-with-lease` to avoid overwriting others' work when force-pushing.
#### Command
```sh
git push --force-with-lease
```
#### Examples
- **Safely force-push your changes.**
```sh
git push --force-with-lease
```
- **Force-push a specific branch with lease protection.**
```sh
git push --force-with-lease origin feature-branch
```
#### Steps
1. Fetch the latest changes: `git fetch origin`
2. Push with lease: `git push --force-with-lease`
3. If rejected, pull and rebase: `git pull --rebase origin main`
4. Resolve conflicts, commit, and retry push
#### Prerequisites
- You must have permission to push to the branch.
#### Warnings
- ⚠️ Never use `--force` unless you are sure. Prefer `--force-with-lease`.
#### Links
- [Medium Article](https://medium.com/@sahilsahilbhatia/git-push-force-with-lease-vs-force-ecae72601e80)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: push, force, safe_
@@ -1,22 +0,0 @@
[⬅️ Back to Table of Contents](../README.md#how-to-use-git-worktree-safely)
# How to Use git worktree Safely
![Category: Worktree](https://img.shields.io/badge/Category-Worktree-blue)
> Work on multiple branches simultaneously without switching.
`git worktree` allows you to manage multiple working directories linked to a single Git repository. It helps developers work on multiple branches simultaneously without switching branches in the same directory.
## Key Topics & Subcommands
- [Check Existing Worktrees](./check-existing-worktrees.md)
- [Create a New Worktree](./create-a-new-worktree.md)
- [Remove a Worktree](./remove-a-worktree.md)
- [Switch Between Worktrees](./switch-between-worktrees.md)
- [Use Worktrees for Temporary Fixes](./use-worktrees-for-temporary-fixes.md)
- [Flags and Their Uses](./flags-and-their-uses.md)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: worktree, branches, advanced_
@@ -1,20 +0,0 @@
[⬅️ Back to Table of Contents](../README.md#miscellaneous-orphaned-git-commands)
# Miscellaneous & Orphaned Git Commands
![Category: Miscellaneous](https://img.shields.io/badge/Category-Miscellaneous-blue)
> Useful Git commands and scripts not referenced elsewhere.
This file collects useful Git commands and scripts that were previously only in the README and not referenced elsewhere in this repository.
## Key Topics & Subcommands
- [git maintenance start](./git-maintenance-start.md): Runs a cronJob in background for the specified repo for periodic maintenance.
- [git request-pull](./git-request-pull.md): Generate a request to pull changes into a repository.
- [View and Clean Up Local Git Branches (Bash)](./view-and-clean-up-local-git-branches-bash.md): Scripts to view and clean up local branches using Bash.
- [View and Clean Up Local Git Branches (PowerShell)](./view-and-clean-up-local-git-branches-powershell.md): Scripts to view and clean up local branches using PowerShell.
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: misc, cleanup, advanced_
@@ -1,20 +0,0 @@
[⬅️ Back to Table of Contents](../README.md#past-commits-of-a-specific-file)
# Past commits of a specific file
![Category: History and Inspection](https://img.shields.io/badge/Category-History%20and%20Inspection-blue)
> See all commits and changes for a specific file.
You can see all commits related to a specific file using Git commands. Here are a few ways to do it:
## Key Topics & Subcommands
- [Show Commit History of a Specific File](./show-commit-history-of-a-specific-file.md)
- [Show Detailed Commit History (With Changes)](./show-detailed-commit-history-with-changes.md)
- [Show Commit History With Author and Date](./show-commit-history-with-author-and-date.md)
- [See Who Last Modified Each Line (Blame)](./see-who-last-modified-each-line-blame.md)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: history, inspection, file_
-19
View File
@@ -1,19 +0,0 @@
[⬅️ Back to Sharing Changes as Patch Files](./sharing-changes-as-patch-files.md)
[⬆️ Previous Step: Apply Diff File](./apply-diff-file.md)
# Patch vs Diff: Quick Reference
![Category: Patch & Diff](https://img.shields.io/badge/Category-Patch%20%26%20Diff-blue)
| Command | Use Case | Preserves Commit Info? | Can Apply With |
|---|---|---|---|
| git diff > file.diff | Share uncommitted changes | ❌ | git apply |
| git format-patch > file.patch | Share committed changes | ✅ | git am |
[➡️ Continue to Next Topic: Pull Changes of Specific Files from a Commit](./pull-changes-of-specific-files-from-a-commit.md)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: patch, diff, reference_
@@ -1,55 +0,0 @@
[⬅️ Back to Table of Contents](../README.md#pull-changes-of-specific-files-from-a-commit)
# Pull Changes of Specific Files from a Commit
![Category: Selective File Restore](https://img.shields.io/badge/Category-Selective%20File%20Restore-blue)
> Restore or pull changes for specific files from a past commit without reverting the entire commit.
How to use git to pull or restore changes for only certain files from a specific commit, without affecting the rest of your working directory or reverting the whole commit. Useful for cherry-picking file-level changes.
#### Command
```sh
git checkout <commit-hash> -- <file1> <file2>
```
#### Examples
- **Restore file1.txt and file2.txt from the specified commit.**
```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
```
- **Restore files using the newer 'git restore' command.**
```sh
git restore --source e8ab7f64fdfcc7bdaaed8d96c0ac26dce035663f path/to/file1.txt path/to/file2.txt
```
#### Steps
1. Checkout the specific files from the desired commit using '`git checkout <commit-hash> -- <file1> <file2`>'.
2. Stage the changes with '`git add <file1> <file2`>'.
3. Commit the changes with a descriptive message.
4. Push your branch and create a pull request if needed.
#### Warnings
- ⚠️ This will overwrite the current working directory versions of the specified files.
- ⚠️ Make sure to commit or stash any local changes to those files before running the command.
#### Links
- [Git Docs: git checkout](https://git-scm.com/docs/git-checkout)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: checkout, restore, file, commit, cherry-pick_
-40
View File
@@ -1,40 +0,0 @@
[⬅️ Back to How to Use git worktree Safely](./how-to-use-git-worktree-safely.md)
[⬆️ Previous Step: Create a New Worktree](./create-a-new-worktree.md)
# Remove a Worktree
![Category: Worktree](https://img.shields.io/badge/Category-Worktree-blue)
#### Command
```sh
git worktree remove <worktree-path>
```
#### Examples
- **Detach a worktree without deleting the files.**
```sh
git worktree remove ../feature-branch
```
- **Remove a hotfix worktree.**
```sh
git worktree remove ../hotfix
```
#### Steps
1. Detach a worktree without deleting the files.
#### Warnings
- ⚠️ Make sure you have committed all changes before removing a worktree.
[➡️ See the Next Step: Switch Between Worktrees](./switch-between-worktrees.md)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: worktree, remove_
@@ -1,40 +0,0 @@
[⬅️ Back to Past commits of a specific file](./past-commits-of-a-specific-file.md)
[⬆️ Previous Step: Show Commit History With Author and Date](./show-commit-history-with-author-and-date.md)
# See Who Last Modified Each Line (Blame)
![Category: History](https://img.shields.io/badge/Category-History-blue)
#### Command
```sh
git blame filename.txt
```
#### Examples
- **Show the last commit that changed each line of the file.**
```sh
git blame filename.txt
```
- **Blame only lines 10 to 20 of a file.**
```sh
git blame -L 10,20 filename.txt
```
#### Steps
1. Shows the last commit that changed each line of the file.
#### Warnings
- ⚠️ Blame can be misleading if the file has been heavily refactored.
[➡️ Continue to Next Topic: Git Clean: Remove Untracked Files and Directories](./git-clean-remove-untracked-files-and-directories.md)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: blame, file, history_
@@ -1,21 +0,0 @@
[⬅️ Back to Table of Contents](../README.md#sharing-changes-as-patch-files)
# Sharing Changes as Patch Files
![Category: Patch & Diff](https://img.shields.io/badge/Category-Patch%20%26%20Diff-blue)
> Generate and share patch files for committed or uncommitted changes.
How to create patch files from your changes for sharing via email, SCP, Slack, or other means. Covers both committed (with full commit metadata) and uncommitted changes.
## Key Topics & Subcommands
- [Create Patch from Last Commit(s)](./create-patch-from-last-commit-s.md)
- [Apply Patch with Commit Metadata](./apply-patch-with-commit-metadata.md)
- [Create Patch from Uncommitted Changes](./create-patch-from-uncommitted-changes.md)
- [Apply Diff File](./apply-diff-file.md)
- [Patch vs Diff: Quick Reference](./patch-vs-diff-quick-reference.md)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: patch, diff, sharing, email, collaboration_
@@ -1,39 +0,0 @@
[⬅️ Back to Past commits of a specific file](./past-commits-of-a-specific-file.md)
# Show Commit History of a Specific File
![Category: History](https://img.shields.io/badge/Category-History-blue)
#### Command
```sh
git log --oneline -- filename.txt
```
#### Examples
- **List all commits that modified `filename.txt`.**
```sh
git log --oneline -- filename.txt
```
- **Show commit history for a different file.**
```sh
git log --oneline -- path/to/anotherfile.js
```
#### Steps
1. Lists all commits that modified `filename.txt`.
#### Related Commands
- git log -p -- filename.txt
- git blame filename.txt
[➡️ See the Next Step: Show Detailed Commit History (With Changes)](./show-detailed-commit-history-with-changes.md)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: log, file, history_
@@ -1,36 +0,0 @@
[⬅️ Back to Past commits of a specific file](./past-commits-of-a-specific-file.md)
[⬆️ Previous Step: Show Detailed Commit History (With Changes)](./show-detailed-commit-history-with-changes.md)
# Show Commit History With Author and Date
![Category: History](https://img.shields.io/badge/Category-History-blue)
#### Command
```sh
git log --pretty=format:"%h - %an, %ar : %s" -- filename.txt
```
#### Examples
- **Display commit hash, author, relative date, and commit message.**
```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
1. Displays commit hash, author, relative date, and commit message.
[➡️ See the Next Step: See Who Last Modified Each Line (Blame)](./see-who-last-modified-each-line-blame.md)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: log, author, date_
@@ -1,40 +0,0 @@
[⬅️ Back to Past commits of a specific file](./past-commits-of-a-specific-file.md)
[⬆️ Previous Step: Show Commit History of a Specific File](./show-commit-history-of-a-specific-file.md)
# Show Detailed Commit History (With Changes)
![Category: History](https://img.shields.io/badge/Category-History-blue)
#### Command
```sh
git log -p -- filename.txt
```
#### Examples
- **Show each commit and the actual changes made to `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
1. Shows each commit and the actual changes made to `filename.txt`.
#### Related Commands
- git log --oneline -- filename.txt
[➡️ See the Next Step: Show Commit History With Author and Date](./show-commit-history-with-author-and-date.md)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: log, diff, file_
-34
View File
@@ -1,34 +0,0 @@
[⬅️ Back to How to Use git worktree Safely](./how-to-use-git-worktree-safely.md)
[⬆️ Previous Step: Remove a Worktree](./remove-a-worktree.md)
# Switch Between Worktrees
![Category: Worktree](https://img.shields.io/badge/Category-Worktree-blue)
#### Command
`cd <worktree-path>`
#### Examples
- **Switch to the worktree directory.**
```sh
cd ../feature-branch
```
- **Switch to a hotfix worktree.**
```sh
cd ../hotfix
```
#### Steps
1. Simply cd into the worktree directory to switch.
[➡️ See the Next Step: Use Worktrees for Temporary Fixes](./use-worktrees-for-temporary-fixes.md)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: worktree, switch_
@@ -1,36 +0,0 @@
[⬅️ Back to How to Use git worktree Safely](./how-to-use-git-worktree-safely.md)
[⬆️ Previous Step: Switch Between Worktrees](./switch-between-worktrees.md)
# Use Worktrees for Temporary Fixes
![Category: Worktree](https://img.shields.io/badge/Category-Worktree-blue)
#### Command
```sh
git worktree add ../hotfix hotfix-branch
```
#### Examples
- **Quickly apply a fix on another branch without leaving your main branch.**
```sh
git worktree add ../hotfix hotfix-branch
```
- **Create a worktree for a bugfix branch.**
```sh
git worktree add ../bugfix bugfix-branch
```
#### Steps
1. Quickly apply a fix on another branch without leaving your main branch.
[➡️ See the Next Step: Flags and Their Uses](./flags-and-their-uses.md)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: worktree, hotfix_
@@ -1,17 +0,0 @@
[⬅️ Back to Table of Contents](../README.md#useful-rare-git-commands-you-never-heard-of)
# Useful Rare Git Commands You Never Heard Of
![Category: Advanced](https://img.shields.io/badge/Category-Advanced-blue)
> A collection of lesser-known but powerful Git commands.
A collection of lesser-known but powerful Git commands. Use these to level up your Git workflow!
## Key Topics & Subcommands
- [git replace <old-commit> <new-commit>](./git-replace-old-commit-new-commit.md): Temporarily substitute one commit for another.
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: rare, advanced, tips_
@@ -1,54 +0,0 @@
[⬅️ Back to Cleanup Branches Fast ⚡](./cleanup-branches-fast.md)
[⬆️ Previous Step: Delete Local Branches Whose Remote is Gone (PowerShell)](./delete-local-branches-whose-remote-is-gone-powershell.md)
# View and Clean Up Local Git Branches (Bash)
![Category: Branch Management](https://img.shields.io/badge/Category-Branch%20Management-blue)
> Scripts to view and clean up local branches using Bash.
#### Examples
- **List local branches without a remote connection.**
```sh
git branch -vv | grep -E '^\s*\S+\s+[^\[]+$'
```
- **Delete local branches without remote tracking.**
```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
1. List local branches.
2. Delete local branches without remote.
3. View branches with deleted remote.
4. Delete stale local branches.
#### Warnings
- ⚠️ Deleting branches is irreversible. Double-check before running destructive commands.
#### ProTips
> [!TIP]
> Use 'git branch -vv' to see tracking info for all branches.
> [!TIP]
> Pipe to 'awk' and 'xargs' for batch deletion.
[➡️ See the Next Step: View and Clean Up Local Git Branches (PowerShell)](./view-and-clean-up-local-git-branches-powershell.md)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: branches, cleanup, bash_
@@ -1,54 +0,0 @@
[⬅️ Back to Cleanup Branches Fast ⚡](./cleanup-branches-fast.md)
[⬆️ Previous Step: View and Clean Up Local Git Branches (Bash)](./view-and-clean-up-local-git-branches-bash.md)
# View and Clean Up Local Git Branches (PowerShell)
![Category: Branch Management](https://img.shields.io/badge/Category-Branch%20Management-blue)
> Scripts to view and clean up local branches using PowerShell.
#### Examples
- **List local branches without a remote connection.**
```sh
git branch -vv | Select-String -NotMatch "origin/"
```
- **Delete local branches without remote tracking.**
```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
1. List local branches.
2. Delete local branches without remote.
3. View branches with deleted remote.
4. Delete stale local branches.
#### Warnings
- ⚠️ Deleting branches is irreversible. Double-check before running destructive commands.
#### ProTips
> [!TIP]
> Use PowerShell's 'Select-String' for flexible filtering.
> [!TIP]
> Automate cleanup with a script for regular maintenance.
[➡️ Continue to Next Topic: Git Command Reference (Full List)](./git-command-reference-full-list.md)
---
_Author: mike-rambil • Updated: 2024-06-10 • Tags: branches, cleanup, powershell_