mirror of
https://github.com/mike-rambil/Advanced-Git.git
synced 2025-12-30 05:59:31 -06:00
fix: setup proper category
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
# Check Existing Worktrees
|
||||
|
||||
|
||||
#### Category
|
||||
Worktree
|
||||
|
||||
#### 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
|
||||
@@ -1,36 +0,0 @@
|
||||
# Create a New Worktree
|
||||
|
||||
|
||||
#### Category
|
||||
Worktree
|
||||
|
||||
#### Command
|
||||
```sh
|
||||
git worktree add <path> <branch>
|
||||
```
|
||||
|
||||
#### 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
|
||||
@@ -1,20 +0,0 @@
|
||||
# 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
|
||||
@@ -1,81 +0,0 @@
|
||||
# Git Clean: Remove Untracked Files and Directories
|
||||
|
||||
|
||||
#### Category
|
||||
Stashing and Cleaning
|
||||
> 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
|
||||
@@ -1,34 +0,0 @@
|
||||
# git clone --mirror <repository>
|
||||
|
||||
|
||||
#### Category
|
||||
Repository Management
|
||||
> 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 <repository>` to create a full backup or migration.
|
||||
|
||||
|
||||
#### Tags
|
||||
`clone`, `mirror`, `backup`
|
||||
|
||||
#### Author
|
||||
mike-rambil
|
||||
|
||||
#### Last Updated
|
||||
2024-06-10
|
||||
@@ -1,82 +0,0 @@
|
||||
# Git Command Reference (Full List)
|
||||
|
||||
|
||||
#### Category
|
||||
Reference
|
||||
> 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 <repository>
|
||||
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 <repository>` to create a full backup or migration.
|
||||
|
||||
|
||||
#### Tags
|
||||
`clone`, `mirror`, `backup`
|
||||
|
||||
#### Author
|
||||
mike-rambil
|
||||
|
||||
#### Last Updated
|
||||
2024-06-10
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
# git init --bare
|
||||
|
||||
|
||||
#### Category
|
||||
Repository Management
|
||||
> 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
|
||||
@@ -1,38 +0,0 @@
|
||||
# git maintenance start
|
||||
|
||||
|
||||
#### Category
|
||||
Maintenance
|
||||
> 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
|
||||
@@ -1,34 +0,0 @@
|
||||
# git replace <old-commit> <new-commit>
|
||||
|
||||
|
||||
#### Category
|
||||
History
|
||||
> 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 <old-commit> <new-commit>` to test or patch history.
|
||||
|
||||
|
||||
#### Tags
|
||||
`replace`, `history`
|
||||
|
||||
#### Author
|
||||
mike-rambil
|
||||
|
||||
#### Last Updated
|
||||
2024-06-10
|
||||
@@ -1,38 +0,0 @@
|
||||
# git request-pull
|
||||
|
||||
|
||||
#### Category
|
||||
Collaboration
|
||||
> Generate a request to pull changes into a repository.
|
||||
|
||||
|
||||
#### Command
|
||||
```sh
|
||||
git request-pull <start> <url> <end>
|
||||
```
|
||||
|
||||
#### 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 <start> <url> <end>` 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
|
||||
@@ -1,51 +0,0 @@
|
||||
# How to Use git push --force-with-lease Safely
|
||||
|
||||
|
||||
#### Category
|
||||
Collaboration
|
||||
> 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
|
||||
@@ -1,193 +0,0 @@
|
||||
# How to Use git worktree Safely
|
||||
|
||||
|
||||
#### Category
|
||||
Worktree
|
||||
> 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 <path> <branch>
|
||||
```
|
||||
|
||||
#### 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 <worktree-path>
|
||||
```
|
||||
|
||||
#### 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 <worktree-path>`
|
||||
|
||||
#### 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
|
||||
|
||||
@@ -1,166 +0,0 @@
|
||||
# Miscellaneous & Orphaned Git Commands
|
||||
|
||||
|
||||
#### Category
|
||||
Miscellaneous
|
||||
> 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 <start> <url> <end>
|
||||
```
|
||||
|
||||
#### 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 <start> <url> <end>` 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
|
||||
|
||||
@@ -1,151 +0,0 @@
|
||||
# Past commits of a specific file
|
||||
|
||||
|
||||
#### Category
|
||||
History and Inspection
|
||||
> 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
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
# Remove a Worktree
|
||||
|
||||
|
||||
#### Category
|
||||
Worktree
|
||||
|
||||
#### Command
|
||||
```sh
|
||||
git worktree remove <worktree-path>
|
||||
```
|
||||
|
||||
#### 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
|
||||
@@ -1,36 +0,0 @@
|
||||
# See Who Last Modified Each Line (Blame)
|
||||
|
||||
|
||||
#### Category
|
||||
History
|
||||
|
||||
#### 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
|
||||
@@ -1,37 +0,0 @@
|
||||
# Show Commit History of a Specific File
|
||||
|
||||
|
||||
#### Category
|
||||
History
|
||||
|
||||
#### 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
|
||||
@@ -1,32 +0,0 @@
|
||||
# Show Commit History With Author and Date
|
||||
|
||||
|
||||
#### Category
|
||||
History
|
||||
|
||||
#### 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
|
||||
@@ -1,36 +0,0 @@
|
||||
# Show Detailed Commit History (With Changes)
|
||||
|
||||
|
||||
#### Category
|
||||
History
|
||||
|
||||
#### 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
|
||||
@@ -1,30 +0,0 @@
|
||||
# Switch Between Worktrees
|
||||
|
||||
|
||||
#### Category
|
||||
Worktree
|
||||
|
||||
#### Command
|
||||
`cd <worktree-path>`
|
||||
|
||||
#### 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
|
||||
@@ -1,32 +0,0 @@
|
||||
# Use Worktrees for Temporary Fixes
|
||||
|
||||
|
||||
#### Category
|
||||
Worktree
|
||||
|
||||
#### 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
|
||||
@@ -1,52 +0,0 @@
|
||||
# Useful Rare Git Commands You Never Heard Of
|
||||
|
||||
|
||||
#### Category
|
||||
Advanced
|
||||
> 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 <old-commit> <new-commit>
|
||||
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 <old-commit> <new-commit>` to test or patch history.
|
||||
|
||||
|
||||
#### Tags
|
||||
`replace`, `history`
|
||||
|
||||
#### Author
|
||||
mike-rambil
|
||||
|
||||
#### Last Updated
|
||||
2024-06-10
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
# View and Clean Up Local Git Branches (Bash)
|
||||
|
||||
|
||||
#### Category
|
||||
Branch Management
|
||||
> 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
|
||||
@@ -1,42 +0,0 @@
|
||||
# View and Clean Up Local Git Branches (PowerShell)
|
||||
|
||||
|
||||
#### Category
|
||||
Branch Management
|
||||
> 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
|
||||
@@ -175,7 +175,10 @@ function renderLastUpdated(date) {
|
||||
|
||||
function renderCategory(category) {
|
||||
if (!category) return '';
|
||||
return renderSection('Category', category);
|
||||
const badge = `}-blue)`;
|
||||
return `\n${badge}\n`;
|
||||
}
|
||||
|
||||
function renderCommandExamples(examples) {
|
||||
|
||||
Reference in New Issue
Block a user