Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,14 @@ If you aren't using any zsh frameworks, or if you're a bash user, do the followi

| Script | Original Source | Description |
| ------ | --------------- | ----------- |
| `git-attic` | Christian Neukirchen's [blog](http://chneukirchen.org/blog/archive/2013/01/a-grab-bag-of-git-tricks.html) | Displays a list of deleted files in your repo. The output is designed to be copy’n’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](https://github.com/mislav/dotfiles) | Show files in the repo larger than a threshold size |
| `git-change-author` | Michael Demmer in [jut-io/git-scripts](https://github.com/jut-io/git-scripts/blob/master/bin/git-change-author) | Change one author/email in the history to another |
| `git-change-log` | John Wiegley's [git-scripts](https://github.com/jwiegley/git-scripts) | turn `git log` output into a complete Changelog for projects that haven't been maintaining one |
| `git-changes` | Michael Markert's [dotfiles](https://github.com/cofi/dotfiles) | List authors in the repo in descending commit-count order |
| `git-churn` | Gary Bernhardt's [dotfiles](https://github.com/garybernhardt/dotfiles/blob/master/bin/git-churn) | 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](http://chneukirchen.org/blog/archive/2013/01/a-grab-bag-of-git-tricks.html) | Adds and commits a file in one command |
| `git-conflicts` | Seth Messer's [bits and bobs](https://github.com/megalithic/bits-and-bobs/) repo | Show files with conflicts |
| `git-copy-branch-name` | Zach Holman's [dotfiles](https://github.com/holman/dotfiles) | Copy the current branch name to the clipboard (OS X Only) |
| `git-credit` | Zach Holman's [dotfiles](https://github.com/holman/dotfiles) | Quicker way to assign credit to another author on the latest commit|
Expand All @@ -106,6 +108,7 @@ If you aren't using any zsh frameworks, or if you're a bash user, do the followi
| `git-ls-object-refs` | Ryan Tomayko's [dotfiles](https://github.com/rtomayko/dotfiles) | Find references to an object with SHA1 in refs, commits, and trees. All of them. |
| `git-maxpack` | John Wiegley's [git-scripts](https://github.com/jwiegley/git-scripts) | Compress a repo's pack files as much as possible |
| `git-move-commits` | Corey Oordt's [git-scripts](https://github.com/coordt/git-scripts/blob/master/git-move-commits) | `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](http://chneukirchen.org/blog/archive/2013/01/a-grab-bag-of-git-tricks.html) | Show commits from the HEAD until the first branching point. Companion script for `git-trail` |
| `git-nuke` | Zach Holman's [dotfiles](https://github.com/holman/dotfiles) | Nukes a branch locally and on the origin remote |
| `git-object-deflate` | Ryan Tomayko's [dotfiles](https://github.com/rtomayko/dotfiles) | Deflate an loose object file and write to standard output |
| `git-outgoing` | Michael Markert's [dotfiles](https://github.com/cofi/dotfiles) | Show commits that are on the local branch that have not been pushed to the tracking branch |
Expand Down Expand Up @@ -135,7 +138,7 @@ If you aren't using any zsh frameworks, or if you're a bash user, do the followi
| `git-submodule-rm` | Greg V's [dotfiles](https://github.com/myfreeweb/dotfiles) | Allows you to remove a submodule easily with `git submodule-rm path/to/submodule` |
| `git-thanks` | Mislav Marohnić's [dotfiles](https://github.com/mislav/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](https://github.com/holman/dotfiles) | Sets up your branch to track a remote branch. Assumes you mean origin/localbranchname |
| `git-trail` | Daniel Hahler's [dotfiles](https://github.com/blueyed/dotfiles/blob/master/usr/bin/git-trail) | Show all branching points in the repo's Git history |
| `git-trail` | Christian Neukirchen's [blog](http://chneukirchen.org/blog/archive/2013/01/a-grab-bag-of-git-tricks.html) | 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-undo-push` | ? | Undoes your last push to branch ($1) of origin |
| `git-unpushed` | Zach Holman's [dotfiles](https://github.com/holman/dotfiles) | Show the diff of everything you haven't pushed to the origin remote yet |
| `git-unreleased` | Mislav Marohnić's [dotfiles](https://github.com/mislav/dotfiles) | Shows git commits since the last tagged version |
Expand Down Expand Up @@ -180,6 +183,8 @@ Here are some helpful aliases for your `~/.gitconfig`

* [git-tips/tips](https://github.com/git-tips/tips) is a collection of git tips

* Christian Neukirchen wrote a great [blog post](http://chneukirchen.org/blog/archive/2013/01/a-grab-bag-of-git-tricks.html) on git that is the source for several scripts in this collection.

* Mislav Marohnić has a good article on git tips on his [blog](http://mislav.net/2010/07/git-tips/). Several of his git scripts are in this collection.

* And when you manage to get your git working directory in a sad state, you can run into the chicken-egg problem where if you just knew what command to man, you could dig yourself out of the hole, but if you knew that, you wouldn't be in the bad place anyway. [Oh Shit, Git!](http://ohshitgit.com/) has a collection of bad situations explained in plain English and how to get yourself out of them.
Expand Down
18 changes: 18 additions & 0 deletions bin/git-attic
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh
# git-attic [-M] [PATH] - list deleted files of Git repositories
#
# Use -M to not show renamed files, and other git-log options as you like.
#
# The output is designed to be copy’n’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
#
# Source: http://chneukirchen.org/blog/archive/2013/01/a-grab-bag-of-git-tricks.html


git log --raw --no-renames --date=short --format="%h %cd" "$@" |
awk '/^[0-9a-f]/ { commit=$1; date=$2 }
/^:/ && $5 == "D" { print date, commit "^:" $6 }' |
git -p column

set -o pipefail
18 changes: 18 additions & 0 deletions bin/git-comma
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env zsh
#
# git comma - like git commit, but adds unknown files automatically
#
# Source: http://chneukirchen.org/blog/archive/2013/01/a-grab-bag-of-git-tricks.html

added=()

# add unknown files...
for arg; do
if [[ -f $arg && -n $(git ls-files -o $arg) ]]; then
git add $arg
added+=($arg)
fi
done

# ...reset them when commit is aborted
git commit ${@:+-o} "$@" || git reset -q -- $added
14 changes: 14 additions & 0 deletions bin/git-neck
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh -e
# git neck [-r] [COMMIT] - show commits until first branching point
#
# Source: http://chneukirchen.org/blog/archive/2013/01/a-grab-bag-of-git-tricks.html

[ "$1" = -r ] && shift && R=-r
COMMIT=$(git rev-parse --no-flags --default HEAD "$@")

# skip first elements of trail
TORSO=$(git trail $R $COMMIT | cut -d' ' -f2 | uniq | sed -n 2p)

# fall back to initial commit on empty trail
: ${TORSO:=$(git rev-list --max-parents=0 HEAD)}
git log --oneline $(git rev-parse --no-revs "$@") $COMMIT...$TORSO
4 changes: 2 additions & 2 deletions bin/git-trail
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh -e
#
# https://github.com/blueyed/dotfiles/blob/master/usr/bin/git-trail
# http://chneukirchen.org/blog/archive/2013/01/a-grab-bag-of-git-tricks.html
#
# git trail [-r] [-t] [COMMIT] - show all branching points in Git history

Expand All @@ -22,5 +22,5 @@ COMMIT=$(git rev-parse --no-flags --default HEAD "$@")
"git name-rev --name-only --refs=\"" mbs[i] "\" " $3 | getline nr
if (nr != "undefined") print $1, $2, nr # skip unreachable commits
}
}
}
}' | git -p column # paginate output