A collection of useful Git aliases for enhanced productivity
A curated set of Git aliases that improve your command-line workflow with better logging, statistics, and repository management commands.
-
git ls- View commit history with a beautiful graph format- Shows date, hash, message, and author in color
- Perfect for quickly scanning commit history
-
git undo- Undo the last commit while keeping changes- Moves the last commit back to your working directory
- Safe way to fix mistakes before re-committing
-
git amend- Fix the last commit- Stages all changes and amends them to the previous commit
- Great for fixing typos or forgotten files
-
git alias- List all configured aliases- Shows all your Git aliases with color-coded output
- Helpful for discovering available shortcuts
-
git sync- Rebase current branch on top of the default branch- Fetches all changes and rebases cleanly
-
git up- Update everything (pull, rebase, submodules)- Comprehensive update command for the entire repository
-
git authors- Show commit counts by author- Lists all contributors with their commit counts
-
git stats "Author Name"- Detailed statistics for a specific author- Shows files changed, lines added/deleted, and ratios
-
git recent- Show recently modified branches- See which branches have been worked on recently
-
git age- Show repository age and commit count- First and last commit dates with total commit count
-
git activity- Show commit activity by hour of day- Visualize when commits are typically made
-
git weekly- Show weekly commit statistics- Track commit activity over time
-
git search "text"- Search commit history for specific content- Find when specific code was added or modified
-
git big- Find the largest files in the repository- Identify files that are bloating the repository
-
git filetypes- Show file type statistics- See the distribution of file extensions
-
git cleanup- Clean up repository- Prunes remote branches, runs garbage collection, removes untracked files
-
git reauthor "old@email.com"- Change author information- Updates all commits from a specific email to your current Git config
- Warning: Rewrites history - use with caution
Clone this repository to your machine:
git clone https://github.com/avanderw/git-templates.git C:\git-templatesConfigure Git to include these aliases globally:
git config --global include.path 'C:/git-templates/.gitalias'Note: Use forward slashes (/) in the path for cross-platform compatibility.
Verify the installation:
git aliasRemove the alias configuration:
git config --global --unset include.pathNavigate to the repository and pull the latest changes:
cd C:\git-templates
git pullConfigure VS Code as your Git editor:
git config --global core.editor "code --wait"Or use Notepad as a simple alternative:
git config --global core.editor notepadConfigure Git to handle Windows line endings properly:
# Convert LF to CRLF on checkout, CRLF to LF on commit
git config --global core.autocrlf trueEnable the Windows Credential Manager for storing Git credentials:
git config --global credential.helper managerConfigure a visual diff tool (example using VS Code):
git config --global diff.tool vscode
git config --global difftool.vscode.cmd 'code --wait --diff $LOCAL $REMOTE'Improve Git performance on Windows:
# Enable parallel index preload
git config --global core.preloadindex true
# Enable file system cache
git config --global core.fscache true
# Increase buffer size for better performance
git config --global http.postBuffer 524288000Set your identity (required for commits):
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"Set the default branch name for new repositories:
git config --global init.defaultBranch mainThis project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details
The hooks have been adapted from Sitebase/git-hooks.