git-extra-commands

A collection of git utilities and useful extra git scripts I've discovered or written, packaged for ease of use with shell frameworks.

Github stars Tracking Chart

git-extra-commands

License
CircleCI
Code Climate
Issue Count
GitHub stars

Table of Contents

git-extra-commands is a ZSH plugin that packages some extra git helper scripts I've found. This collection (and the scripts that I wrote in it) is licensed with the Apache Version 2 license.

However, some of the scripts in this collection came from other sources and may have different licensing - if they do, their license information is included inline in the script source.

This collection doesn't actually require ZSH, but packaging it as a ZSH plugin makes it more convenient for people using a ZSH framework to use this collection.

If you wrote one of these scripts and want it removed from this collection, please either make a PR and/or file an issue against the repo and I will remove it.

Included Scripts, Script, Original Source, Description, ------, ---------------, -----------, git-add-username-remote, Ryan Tomayko's dotfiles, Adds a remote for the current repository for the given github username., git-age, Kristoffer Gronlund's wiki, A git-blame viewer, written using PyGTK., git-attic, Christian Neukirchen's blog, Displays a list of deleted files in your repo. The output is designed to be copy and pasted: Pass the second field to git show to display the file contents, or just select the hash without ^ to see the commit where removal happened., git-big-file, Mislav Marohnić's dotfiles, Show files in the repo larger than a threshold size., git-branch-name, Joe Block jpb@unixorn.net, Prints the current branch name in automation-friendly format., git-branch-rebaser, Vengada Rangaraju krangaraju@castlighthealth.com, Kicks off an interactive rebase of all the commits on your branch. Including pushed commits, so be careful., git-change-author, Michael Demmer in jut-io/git-scripts, Change one author/email in the history to another., git-change-log, John Wiegley's git-scripts, Transform git log output into a complete Changelog for projects that haven't been maintaining one., git-changes, Michael Markert's dotfiles, List authors in the repo in descending commit-count order., git-churn, Gary Bernhardt's dotfiles, Show which files are getting changed most often in the repository., git-clone-subset, Rodrigo Silva (MestreLion) linux@rodrigosilva.com, Uses git clone and git filter-branch to remove from the clone all files but the ones requested, along with their associated commit history., git-comma, Christian Neukirchen's blog, Adds and commits a file in one command, git-conflicts, Seth Messer's bits and bobs repo, Show files with conflicts, git-copy-branch-name, Zach Holman's dotfiles, Copy the current branch's name to the clipboard (macOS Only)., git-credit, Zach Holman's dotfiles, Quicker way to assign credit to another author on the latest commit., git-current-branch, Joe Block jpb@unixorn.net, Prints the name of the current branch, mainly useful in automation scripts., git-cut-branch, Ryan Tomayko's dotfiles, Create a new branch pointed at HEAD and reset the current branch to the head of its tracking branch, git-delete-local-merged, From a deleted post by @tekkub, Delete all local branches that have been merged into HEAD., git-delete-merged-branches, ?, Purges all branches that have been merged to a target branch (defaults to branches merged to master)., git-delete-tag, Joe Block jpb@unixorn.net, Delete a tag, both locally and from the origin remote., git-diff-last, Sebastian Schuberth, Show the last change made to a file in the repository., git-divergence, Gary Bernhardt's dotfiles, Shows differences between local branch and its tracking branch., git-edit-conflicts, Joe Block jpb@unixorn.net, Edit the files that are marked as conflicted during a merge/rebase in your $EDITOR/$VISUAL., git-find-dirty, Matthew McCullough's scripts repository, git-flush, John Wiegley's git-scripts, Compact your reposistory by dropping all reflogs, stashes, and other cruft that may be bloating your pack files., git-force-mtimes, John Wiegley's git-scripts, Sets mtimes of all files in the reprository their last change date based on git's log. Useful to avoid too new dates after a checkout confusing make or rake., git-forest, Jan Engelhardt, Prints a text-based tree visualisation of your repository. Requires Git.pm, git-git, Joe Block jpb@unixorn.net, Typing git git foo will make git do a git foo instead of complaining., git-github-open, ?, Open GitHub file/blob page for FILE on LINE., git-gitlab-mr, Noel Cower's gist, Open a merge request on GitLab, git-ignored, ?, Show files being ignored by git in the repo., git-improved-merge, Mislav Marohnić's dotfiles, Sophisticated git merge with integrated CI check and automatic cleanup., git-incoming, Michael Markert's dotfiles, Show commits in the tracking branch that are not in the local branch., git-lines, Neil Killeen nkilleen@castlighthealth.com, Gives you a list of author names with the number of lines last updated by that user in files in the current directory tree with the extension specified., git-ls-object-refs, Ryan Tomayko's dotfiles, Find references to an object with SHA1 in refs, commits, and trees. All of them., git-maildiff, Sanjeev Kumar's blogpost, A simple git command to email diff in color to reviewer/ co-worker., git-maxpack, John Wiegley's git-scripts, Compress a repo's pack files as much as possible., git-move-commits, Corey Oordt's git-scripts, git move-commits num-commits correct-branch moves the last n commits to correct-branch (creating it if necessary)., git-neck, Christian Neukirchen's blog, Show commits from the HEAD until the first branching point. Companion script for git-trail., git-nuke, Zach Holman's dotfiles, Nukes a branch locally and on the origin remote., git-object-deflate, Ryan Tomayko's dotfiles, Deflate an loose object file and write to standard output., git-outgoing, Michael Markert's dotfiles, Show commits that are on the local branch that have not been pushed to the tracking branch., git-overwritten, Mislav Marohnić's dotfiles, Aggregates git blame information about original owners of lines changed or removed in the '...' diff., git-pie-ify, JeeBak Kim's gist, git pie-ify pattern replacement, git-plotrepo, Matthew McCullogh's scripts collection, Uses dot to draw a graph of the repository., git-promote, Trevor's Improving My git Workflow blog post (404 now), Promotes a local topic branch to a remote tracking branch of the same name., git-prune-branches, Michael Demmer in jut-io/git-scripts, Deletes each fully merged branch after prompting for confirmation, than asks if you want the deleted branches deleted from your upstream remotes., git-pruneall, Ryan Tomayko's dotfiles, Prune branches from specified remotes, or all remotes when no remote is specified., git-publish, Michael Markert's dotfiles, git publish remote [remote-branch], git-purge-from-history, David Underhill’s blog, Permanently delete files or folders from your git repository., git-pylint, Joe Block jpb@unixorn.net, Runs pylint on any .py files modified or added in the git status output., git-rank-contributors, William Morgan wmorgan-git-wt-add@masanjin.net, Rummages through the changelog and orders contributors by the size of the diffs they're responsible for., git-rebase-authors, Mislav Marohnić's dotfiles, Adds authorship info to interactive git rebase output, git-rebase-theirs, Rodrigo Silva (MestreLion) linux@rodrigosilva.com, Resolve rebase conflicts by favoring 'theirs' version., git-recently-checkedout-branches, Mislav Marohnić's dotfiles, Shows timestamp and name of recently checked-out branches in reverse chronological order., git-rel, Ryan Tomayko's dotfiles, Shows the relationship between the current branch and ref>*. With no ref, the current branch's remote tracking branch is used., git-related, Mislav Marohnić's dotfiles, Show other files that often get changed in commits that touch <file>., git-rename-branches, Rodrigo Silva (MestreLion) linux@rodrigosilva.com, Rename multiple branches that start with a given name., git-reset-with-fire, Joe Block jpb@unixorn.net, Hard reset the working directory, then zap any files not known to git., git-restore-mtime, Rodrigo Silva (MestreLion) linux@rodrigosilva.com, Change mtime of files based on commit date of last change., git-rm-deleted-from-repo, Joe Block jpb@unixorn.net, Removes files you deleted with rm from the repo for you., git-root-directory, Joe Block jpb@unixorn.net, Prints the path to the root of the git repository you're in., git-run-command-on-revisions, Gary Bernhardt's dotfiles, Runs a given command over a range of Git revisions., git-shamend, Danielle Sucher's git-shamend blog post, Amends your staged changes as a fixup (keeping the pre-existing commit message) to the specified commit, or HEAD if no revision is specified., git-show-overwritten, Mislav Marohnić's dotfiles, Aggregates git blame information about the original owners of lines changed or removed in the '...' diff., git-sp, A. Schwarz's git-sp, "Simple push", single short command to commit, and push. Use -a flag to add all files to commit., git-switch, Andrew Steele's dotfiles, Make it easier to switch to a branch by a substring of its name. More useful if you are good about deleting branches which have been merged upstream and if your branch names include unique identifiers like ticket/issue numbers., git-submodule-rm, Greg V's dotfiles & Pascal Sommer, Allows you to remove a submodule easily with git submodule-rm path/to/submodule., git-tag-and-sign, ?, Create and sign a new tag, git-thanks, Mislav Marohnić's dotfiles, List the contributors to a repository in descending commit order, even if their contribution has been completely replaced., git-track, Zach Holman's dotfiles, Sets up your branch to track a remote branch. Assumes you mean origin/localbranchname., git-trail, Christian Neukirchen's blog, Show all branching points in the repo's Git history so you can see how to reach commits in the current branch from other branches., git-undelete, ?, Undeletes a file., git-undo-push, ?, Undoes your last push to branch $1 of origin, git-unpushed, Zach Holman's dotfiles, Show the diff of everything you haven't pushed to the origin remote yet, git-unreleased, Mislav Marohnić's dotfiles, Shows git commits since the last tagged version., git-up, Ryan Tomayko's dotfiles, git-upstream-sync, Joe Block jpb@unixorn.net, Fetches upstream/yourforkname and rebases it into your local fork, then pushes to your origin remote., git-what-the-hell-just-happened, Gary Bernhardt's dotfiles, Show what just happened., git-when-merged, Michael Haggerty git-when-merged, Find when a commit was merged into one or more branches., git-where, Mislav Marohnić's dotfiles, Shows where a particular commit falls between releases., git-whoami, Peter Eisentraut, Shows what username & email you have configured for the repo you're in, git-winner, Garry Dolley https://github.com/up_the_irons/git-winner, Shows what authors have made the most commits, both by number of commits and by number of lines changed., git-wordiness, Noel Cower, Shows how wordy people's commit messages are. Useful for shaming the folks who commit atrocities like git commit -m fixup, git-wtf, William Morgan wmorgan-git-wt-add@masanjin.net, git-wtf displays the state of your repository in a readable, easy-to-scan format. It's useful for getting a summary of how a branch relates to a remote server, and for wrangling many topic branches., github-open, Ryan Tomayko's dotfiles, ## Useful git aliases

Here are some helpful aliases for your ~/.gitconfig, alias, Description, -----, -----------, ahead-of-master = log --oneline origin/master..HEAD, Show commits that haven't made it to master yet., fetch-pull-requests = fetch origin '+refs/pull/*/head:refs/remotes/origin/pull/*', Fetch pull requests from github so you can git checkout pull/123 and test them locally., roots = log --all --oneline --decorate --max-parents=0, Show the root commits., unpushed = log @{u}.., Show which commits have not been pushed to the tracking branch and are safe to amend/rebase., work-in-progress = rebase -i @{u}, Starts an interactive rebase of all the commits you haven't pushed yet. Handy for collapsing a bunch of work-in-progress snapshots into logical commits before pushing, without having to worry about accidentally squashing a commit someone else has already referred to., ## Installing

Pre-requisites

  • A relatively recent version of git. The version of git Apple includes in macOS is very stale. You should really brew install git to get the current version if you're on macOS - if not for features, for security updates.
  • Python 3+
  • Ruby 2.2+

zgen

If you're using zgen:

  1. Add zgen load unixorn/git-extra-commands to your .zshrc along with your other zgen load commands.
  2. zgen reset && zgen save

Antigen

If you're using Antigen:

  1. Add antigen bundle unixorn/git-extra-commands to your .zshrc where you've listed your other plugins.
  2. Close and reopen your Terminal/iTerm window to refresh context and use the plugin. Alternatively, you can run antigen bundle unixorn/git-extra-commands in a running shell to have antigen load the new plugin.

oh-my-zsh

If you're using oh-my-zsh:

  1. In the command line, change to oh-my-zsh's custom plugin directory :

    cd ~/.oh-my-zsh/custom/plugins/

  2. Clone the repository into a new git-extra-commands directory:

    git clone https://github.com/unixorn/git-extra-commands.git git-extra-commands

  3. Edit your ~/.zshrc and add git-extra-commands – same as clone directory – to the list of plugins to enable:

    plugins=( ... git-extra-commands )

  4. Then, restart your terminal application to refresh context and use the plugin. Alternatively, you can source your current shell configuration:

    source ~/.zshrc

Bash / Manual Installation

Nothing here actually requires you to use ZSH or zgen, that's just a convenient distribution method for anyone using a ZSH framework.

If you aren't using any ZSH frameworks, or if you're using bash, fish or another shell, do the following steps:

  1. git clone this repository
  2. Add cloneDirectory/bin to your $PATH in your shell's startup file.

Other useful git stuff

Articles / Blog posts / Books

External Git Utilities

  • bfg repo-cleaner - Removes large or troublesome blobs like git filter-branch does, but faster.
  • bitbucket-git-helpers - Helper scripts to allow you to create bitbucket PRs from a shell session.
  • blackbox - Tom Limoncelli open sourced the tool they use at Stack Exchange to use GPG to store secrets in a git repository.
  • branch-manager - ZSH plugin for branch management
  • commit-helper - A python script that helps you write commits following commit conventions.
  • diff-so-fancy - Better looking git diffs
  • git-aliases.zsh - Peter Hurford's git plugin which you may prefer to the git plugin from oh-my-zsh.
  • git-also - Shows what files are most often committed with a given file in the repository.
  • git-amend - Bash script to amend older commits with staged changes.
  • git-branch-status - A git utility to make managing large number of branches either across many remotes easier. Branch status allows comparing all branches against their upstream or any arbitrary branch to show the number of commit differences.
  • git-branches - Prints the commit behind/ahead counts for branches.
  • git-bump - Hook scripts to automatically bump the version file in a repository
  • git-chart - A python script that builds charts from a git repository
  • git-complete-urls - ZSH plugin to enhance git completion to include in the remotes completion (e.g. from git clone) any URL in the clipboard.
  • git-cop - Enforces Git rebase workflow with consistent Git commits for a clean and easy to read/debug project history.
  • git-crypt - Enables transparent encryption and decryption of files in a git repository. Files which you choose to protect are encrypted when committed, and decrypted when checked out.
  • git-deploy-s3 - Keeps your git repo's assets in sync with Amazon S3.
  • git-diffall - Provides a directory based diff mechanism for git.
  • git-extend - Extend Git builtins with command wrappers.
  • git-fastclone - Think git clone --recursive on steroids. If you're doing repeated checkouts of a given repo on a machine (like a ci box), git-fastclone will speed things up considerably.
  • git-flow-completion - Bash, Fish and Zsh completion support for git-flow
  • git-follow - Follow lifetime changes of a pathspec.
  • git-graph - creates a Graphviz graph showing the high-level structure of a repository's history.
  • git-gutter - Plugin for Sublime Text 2/3 to display the git diff in the edit window gutter.
  • git-it-on.zsh - Another plugin by Peter Hurford that adds a gitit command that will open your current directory on github, in your current branch.
  • git-quick-stats - A simple and efficient way to access various statistics in git repository.
  • git-repo-updater - Allows you to easily update multiple git repositories at once.
  • git-secrets - Prevents you from committing secrets and credentials into git repositories.
  • git-standup - Recall what you did on the last working day. Can work in a directory full of git repos to see a consolidated view of all work in all the repos.
  • git-stashd - Autostashing daemon for dirty worktrees.
  • git-submodule-tools - A collection of scripts that should help make life with git submodules easier.
  • git-sweep - A utility script to remove branches that have been merged to master.
  • git-todo - helper script to show all the todo entries in your repo.
  • git-up (gem) - Fetch and rebase all locally-tracked remote branches.
  • git-up (python) - Python implementation of Aanand's original ruby gem
  • git-wayback-machine - A simple script to quickly navigate a project's state through it's GIT history
  • git_history_visualizer - python script to visualize the history of files in a git repository
  • gitbaby - Helper scripts to manage your git repositories
  • gitgo - Open a GitHub/Gitlab hosted repository in your browser via the command line (macOS only).
  • gitsh - An interactive shell for git. From within gitsh you can issue any git command, even using your local aliases and configuration.
  • hitch - Allows developers to be properly credited when Pair Programming and using git.
  • hub - A command line tool that wraps git in order to extend it with extra features and commands that make working with GitHub easier.
  • joe - Generates .gitignore files from the command line for you.
  • mergepbx - Helper script for merging XCode project files.
  • xcode-build-scripts - Helper scripts to use with XCode projects

Miscellaneous Tips

Rewrite git:// with https://

git config --global url."https://github".insteadOf git://github

or replace with ssh

Use ssh instead of https://

git config --global url."git@github.com:".insteadOf "https://github.com/"

Credit: @grawity & @hansdg1 by way of Kovrinic

Contributing

  • Please include an entry both in the credits section of README.md for any scripts and a credit comment in the script itself in your PRs so authors get their work credited correctly.
  • Please use #!/usr/bin/env interpreter instead of a direct path to the interpreter, this makes it easier for people to use more recent versions when the ones packaged with their OS (macOS and CentOS, I'm looking at you!) are stale.

Overview

Name With Ownerunixorn/git-extra-commands
Primary LanguageShell
Program languageRuby (Language Count: 4)
Platform
License:Apache License 2.0
Release Count0
Created At2014-09-21 16:19:32
Pushed At2024-05-08 13:36:44
Last Commit At
Stargazers Count1k
Watchers Count17
Fork Count90
Commits Count1.5k
Has Issues Enabled
Issues Count11
Issue Open Count0
Pull Requests Count598
Pull Requests Open Count2
Pull Requests Close Count26
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private
To the top