diff --git a/contents/check-existing-worktrees.md b/contents/check-existing-worktrees.md new file mode 100644 index 0000000..7bfea78 --- /dev/null +++ b/contents/check-existing-worktrees.md @@ -0,0 +1,31 @@ +# 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 +``` + + +#### Steps +1. List all active worktrees. + + +#### Tags +`worktree`, `list` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 diff --git a/contents/create-a-new-worktree.md b/contents/create-a-new-worktree.md new file mode 100644 index 0000000..39766c4 --- /dev/null +++ b/contents/create-a-new-worktree.md @@ -0,0 +1,35 @@ +# Create a New Worktree + + +![Category: Worktree](https://img.shields.io/badge/Category-Worktree-blue) + +#### Command +```sh +git worktree add +``` + +#### Examples +- **Create a new worktree for the feature branch.** + + +```sh +git worktree add ../feature-branch feature +``` + + +#### Steps +1. Create a worktree linked to a specific branch. + + +#### Prerequisites +- The target path must not already be a git repository. + + +#### Tags +`worktree`, `add` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 diff --git a/contents/flags-and-their-uses.md b/contents/flags-and-their-uses.md new file mode 100644 index 0000000..d401322 --- /dev/null +++ b/contents/flags-and-their-uses.md @@ -0,0 +1,20 @@ +# 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. + + +#### Tags +`worktree`, `flags` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 diff --git a/contents/git-clean-remove-untracked-files-and-directories.md b/contents/git-clean-remove-untracked-files-and-directories.md new file mode 100644 index 0000000..b037953 --- /dev/null +++ b/contents/git-clean-remove-untracked-files-and-directories.md @@ -0,0 +1,80 @@ +# 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 +``` + + +#### 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) + + +#### Tags +`clean`, `untracked`, `workspace` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 diff --git a/contents/git-clone-mirror-repository.md b/contents/git-clone-mirror-repository.md new file mode 100644 index 0000000..ff5573c --- /dev/null +++ b/contents/git-clone-mirror-repository.md @@ -0,0 +1,33 @@ +# git clone --mirror + + +![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 +``` + + +#### Steps +1. Run `git clone --mirror ` to create a full backup or migration. + + +#### Tags +`clone`, `mirror`, `backup` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 diff --git a/contents/git-command-reference-full-list.md b/contents/git-command-reference-full-list.md new file mode 100644 index 0000000..42ece93 --- /dev/null +++ b/contents/git-command-reference-full-list.md @@ -0,0 +1,81 @@ +# 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. + + +#### Tags +`reference`, `all-commands` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 + +--- + +### Subcommands +#### git init --bare +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 +``` + + +#### Steps +1. Run `git init --bare my-repo.git` to create a bare repository. + + +#### Tags +`init`, `bare`, `repository` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 + +#### git clone --mirror +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 +``` + + +#### Steps +1. Run `git clone --mirror ` to create a full backup or migration. + + +#### Tags +`clone`, `mirror`, `backup` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 + diff --git a/contents/git-init-bare.md b/contents/git-init-bare.md new file mode 100644 index 0000000..1dd15e7 --- /dev/null +++ b/contents/git-init-bare.md @@ -0,0 +1,33 @@ +# 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 +``` + + +#### Steps +1. Run `git init --bare my-repo.git` to create a bare repository. + + +#### Tags +`init`, `bare`, `repository` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 diff --git a/contents/git-maintenance-start.md b/contents/git-maintenance-start.md new file mode 100644 index 0000000..8c97804 --- /dev/null +++ b/contents/git-maintenance-start.md @@ -0,0 +1,37 @@ +# 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. + + +#### Command +```sh +git maintenance start +``` + +#### Examples +- **Enable background maintenance for your repository.** + + +```sh +git maintenance start +``` + + +#### Steps +1. Run `git maintenance start` in your repository. + + +#### Links +- [Official Docs](https://git-scm.com/docs/git-maintenance) + + +#### Tags +`maintenance`, `automation` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 diff --git a/contents/git-replace-old-commit-new-commit.md b/contents/git-replace-old-commit-new-commit.md new file mode 100644 index 0000000..e9fa6b0 --- /dev/null +++ b/contents/git-replace-old-commit-new-commit.md @@ -0,0 +1,33 @@ +# git replace + + +![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 +``` + + +#### Steps +1. Run `git replace ` to test or patch history. + + +#### Tags +`replace`, `history` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 diff --git a/contents/git-request-pull.md b/contents/git-request-pull.md new file mode 100644 index 0000000..ac25847 --- /dev/null +++ b/contents/git-request-pull.md @@ -0,0 +1,37 @@ +# git request-pull + + +![Category: Collaboration](https://img.shields.io/badge/Category-Collaboration-blue) +> Generate a request to pull changes into a repository. + + +#### Command +```sh +git request-pull +``` + +#### Examples +- **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 +``` + + +#### Steps +1. Run `git request-pull ` to generate a pull request message. + + +#### Links +- [Official Docs](https://git-scm.com/docs/git-request-pull) + + +#### Tags +`collaboration`, `pull-request` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 diff --git a/contents/how-to-use-git-push-force-with-lease-safely.md b/contents/how-to-use-git-push-force-with-lease-safely.md new file mode 100644 index 0000000..8861f15 --- /dev/null +++ b/contents/how-to-use-git-push-force-with-lease-safely.md @@ -0,0 +1,50 @@ +# 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 +``` + + +#### 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) + + +#### Tags +`push`, `force`, `safe` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 diff --git a/contents/how-to-use-git-worktree-safely.md b/contents/how-to-use-git-worktree-safely.md new file mode 100644 index 0000000..3b27840 --- /dev/null +++ b/contents/how-to-use-git-worktree-safely.md @@ -0,0 +1,192 @@ +# 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. + + +#### Tags +`worktree`, `branches`, `advanced` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 + +--- + +### Subcommands +#### Check Existing Worktrees + +#### Command +```sh +git worktree list +``` + +#### Examples +- **List all active worktrees.** + + +```sh +git worktree list +``` + + +#### Steps +1. List all active worktrees. + + +#### Tags +`worktree`, `list` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 + +#### Create a New Worktree + +#### Command +```sh +git worktree add +``` + +#### Examples +- **Create a new worktree for the feature branch.** + + +```sh +git worktree add ../feature-branch feature +``` + + +#### Steps +1. Create a worktree linked to a specific branch. + + +#### Prerequisites +- The target path must not already be a git repository. + + +#### Tags +`worktree`, `add` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 + +#### Remove a Worktree + +#### Command +```sh +git worktree remove +``` + +#### Examples +- **Detach a worktree without deleting the files.** + + +```sh +git worktree remove ../feature-branch +``` + + +#### Steps +1. Detach a worktree without deleting the files. + + +#### Warnings +- ⚠️ Make sure you have committed all changes before removing a worktree. + + +#### Tags +`worktree`, `remove` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 + +#### Switch Between Worktrees + +#### Command +`cd ` + +#### Examples +- **Switch to the worktree directory.** + + +```sh +cd ../feature-branch +``` + + +#### Steps +1. Simply cd into the worktree directory to switch. + + +#### Tags +`worktree`, `switch` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 + +#### Use Worktrees for Temporary Fixes + +#### 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 +``` + + +#### Steps +1. Quickly apply a fix on another branch without leaving your main branch. + + +#### Tags +`worktree`, `hotfix` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 + +#### 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. + + +#### Tags +`worktree`, `flags` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 + diff --git a/contents/miscellaneous-orphaned-git-commands.md b/contents/miscellaneous-orphaned-git-commands.md new file mode 100644 index 0000000..0b4ad9a --- /dev/null +++ b/contents/miscellaneous-orphaned-git-commands.md @@ -0,0 +1,165 @@ +# 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. + + +#### Tags +`misc`, `cleanup`, `advanced` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 + +--- + +### Subcommands +#### git maintenance start +Runs a cronJob in background for the specified repo for periodic maintenance. + +#### Command +```sh +git maintenance start +``` + +#### Examples +- **Enable background maintenance for your repository.** + + +```sh +git maintenance start +``` + + +#### Steps +1. Run `git maintenance start` in your repository. + + +#### Links +- [Official Docs](https://git-scm.com/docs/git-maintenance) + + +#### Tags +`maintenance`, `automation` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 + +#### git request-pull +Generate a request to pull changes into a repository. + +#### Command +```sh +git request-pull +``` + +#### Examples +- **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 +``` + + +#### Steps +1. Run `git request-pull ` to generate a pull request message. + + +#### Links +- [Official Docs](https://git-scm.com/docs/git-request-pull) + + +#### Tags +`collaboration`, `pull-request` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 + +#### View and Clean Up Local Git Branches (Bash) +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 +``` + + +#### 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. + + +#### Tags +`branches`, `cleanup`, `bash` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 + +#### View and Clean Up Local Git Branches (PowerShell) +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 } +``` + + +#### 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. + + +#### Tags +`branches`, `cleanup`, `powershell` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 + diff --git a/contents/past-commits-of-a-specific-file.md b/contents/past-commits-of-a-specific-file.md new file mode 100644 index 0000000..a4752f1 --- /dev/null +++ b/contents/past-commits-of-a-specific-file.md @@ -0,0 +1,150 @@ +# 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: + + +#### Tags +`history`, `inspection`, `file` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 + +--- + +### Subcommands +#### Show Commit History of a Specific File + +#### Command +```sh +git log --oneline -- filename.txt +``` + +#### Examples +- **List all commits that modified `filename.txt`.** + + +```sh +git log --oneline -- filename.txt +``` + + +#### Steps +1. Lists all commits that modified `filename.txt`. + + +#### Tags +`log`, `file`, `history` + +#### Related Commands +- git log -p -- filename.txt +- git blame filename.txt + + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 + +#### Show Detailed Commit History (With Changes) + +#### 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 +``` + + +#### Steps +1. Shows each commit and the actual changes made to `filename.txt`. + + +#### Tags +`log`, `diff`, `file` + +#### Related Commands +- git log --oneline -- filename.txt + + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 + +#### Show Commit History With Author and Date + +#### 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 +``` + + +#### Steps +1. Displays commit hash, author, relative date, and commit message. + + +#### Tags +`log`, `author`, `date` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 + +#### See Who Last Modified Each Line (Blame) + +#### Command +```sh +git blame filename.txt +``` + +#### Examples +- **Show the last commit that changed each line of the file.** + + +```sh +git blame 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. + + +#### Tags +`blame`, `file`, `history` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 + diff --git a/contents/remove-a-worktree.md b/contents/remove-a-worktree.md new file mode 100644 index 0000000..dc14922 --- /dev/null +++ b/contents/remove-a-worktree.md @@ -0,0 +1,35 @@ +# Remove a Worktree + + +![Category: Worktree](https://img.shields.io/badge/Category-Worktree-blue) + +#### Command +```sh +git worktree remove +``` + +#### Examples +- **Detach a worktree without deleting the files.** + + +```sh +git worktree remove ../feature-branch +``` + + +#### Steps +1. Detach a worktree without deleting the files. + + +#### Warnings +- ⚠️ Make sure you have committed all changes before removing a worktree. + + +#### Tags +`worktree`, `remove` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 diff --git a/contents/see-who-last-modified-each-line-blame.md b/contents/see-who-last-modified-each-line-blame.md new file mode 100644 index 0000000..78f4c63 --- /dev/null +++ b/contents/see-who-last-modified-each-line-blame.md @@ -0,0 +1,35 @@ +# 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 +``` + + +#### 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. + + +#### Tags +`blame`, `file`, `history` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 diff --git a/contents/show-commit-history-of-a-specific-file.md b/contents/show-commit-history-of-a-specific-file.md new file mode 100644 index 0000000..abb9a69 --- /dev/null +++ b/contents/show-commit-history-of-a-specific-file.md @@ -0,0 +1,36 @@ +# 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 +``` + + +#### Steps +1. Lists all commits that modified `filename.txt`. + + +#### Tags +`log`, `file`, `history` + +#### Related Commands +- git log -p -- filename.txt +- git blame filename.txt + + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 diff --git a/contents/show-commit-history-with-author-and-date.md b/contents/show-commit-history-with-author-and-date.md new file mode 100644 index 0000000..6b7ed70 --- /dev/null +++ b/contents/show-commit-history-with-author-and-date.md @@ -0,0 +1,31 @@ +# 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 +``` + + +#### Steps +1. Displays commit hash, author, relative date, and commit message. + + +#### Tags +`log`, `author`, `date` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 diff --git a/contents/show-detailed-commit-history-with-changes.md b/contents/show-detailed-commit-history-with-changes.md new file mode 100644 index 0000000..5bb0925 --- /dev/null +++ b/contents/show-detailed-commit-history-with-changes.md @@ -0,0 +1,35 @@ +# 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 +``` + + +#### Steps +1. Shows each commit and the actual changes made to `filename.txt`. + + +#### Tags +`log`, `diff`, `file` + +#### Related Commands +- git log --oneline -- filename.txt + + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 diff --git a/contents/switch-between-worktrees.md b/contents/switch-between-worktrees.md new file mode 100644 index 0000000..e11595c --- /dev/null +++ b/contents/switch-between-worktrees.md @@ -0,0 +1,29 @@ +# Switch Between Worktrees + + +![Category: Worktree](https://img.shields.io/badge/Category-Worktree-blue) + +#### Command +`cd ` + +#### Examples +- **Switch to the worktree directory.** + + +```sh +cd ../feature-branch +``` + + +#### Steps +1. Simply cd into the worktree directory to switch. + + +#### Tags +`worktree`, `switch` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 diff --git a/contents/use-worktrees-for-temporary-fixes.md b/contents/use-worktrees-for-temporary-fixes.md new file mode 100644 index 0000000..2e4aad2 --- /dev/null +++ b/contents/use-worktrees-for-temporary-fixes.md @@ -0,0 +1,31 @@ +# 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 +``` + + +#### Steps +1. Quickly apply a fix on another branch without leaving your main branch. + + +#### Tags +`worktree`, `hotfix` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 diff --git a/contents/useful-rare-git-commands-you-never-heard-of.md b/contents/useful-rare-git-commands-you-never-heard-of.md new file mode 100644 index 0000000..97c766a --- /dev/null +++ b/contents/useful-rare-git-commands-you-never-heard-of.md @@ -0,0 +1,51 @@ +# 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! + + +#### Tags +`rare`, `advanced`, `tips` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 + +--- + +### Subcommands +#### git replace +Temporarily substitute one commit for another. + +#### Command +```sh +git replace abc123 def456 +``` + +#### Examples +- **Temporarily replace commit abc123 with def456.** + + +```sh +git replace abc123 def456 +``` + + +#### Steps +1. Run `git replace ` to test or patch history. + + +#### Tags +`replace`, `history` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 + diff --git a/contents/view-and-clean-up-local-git-branches-bash.md b/contents/view-and-clean-up-local-git-branches-bash.md new file mode 100644 index 0000000..14112aa --- /dev/null +++ b/contents/view-and-clean-up-local-git-branches-bash.md @@ -0,0 +1,41 @@ +# 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 +``` + + +#### 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. + + +#### Tags +`branches`, `cleanup`, `bash` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10 diff --git a/contents/view-and-clean-up-local-git-branches-powershell.md b/contents/view-and-clean-up-local-git-branches-powershell.md new file mode 100644 index 0000000..20a2f21 --- /dev/null +++ b/contents/view-and-clean-up-local-git-branches-powershell.md @@ -0,0 +1,41 @@ +# 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 } +``` + + +#### 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. + + +#### Tags +`branches`, `cleanup`, `powershell` + +#### Author +mike-rambil + +#### Last Updated +2024-06-10