Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
0731851
Add git-already-merged
Oct 7, 2019
d78c1b8
More usefull scripts for daily work
Mar 20, 2020
fad332c
Add git-fat-objects
jwiegley Apr 16, 2020
b3d9243
admit '--dates' switch for arbitrary branch comparisons
bill-auger Feb 23, 2019
99b6fec
implement remote fetching per user-defined frequency
bill-auger May 15, 2019
5a39497
add .gitignore
bill-auger May 15, 2019
d3e50c3
sort by date when dates are shown
bill-auger Aug 28, 2019
cacb997
housekeeping
bill-auger May 25, 2020
512daf4
support user-defined config via cfg file or env vars
bill-auger May 25, 2020
23a4d1d
merge: git-branch-status
bill-auger May 27, 2020
4b07ca9
Merge pull request #42 from bill-auger/master
jwiegley Aug 7, 2022
85aee80
Merge pull request #41 from honzakuzel1989/git-done-merge-release
jwiegley Aug 7, 2022
9a2ce06
chore: Fix most shell deprecations
hyperupcall Jan 6, 2023
041e6d9
chore: Fix POSIX shell syntax errors
hyperupcall Jan 6, 2023
3983eca
chore: Fix miscellaneous bugs
hyperupcall Jan 6, 2023
ef10174
chore: Improve path quoting
hyperupcall Jan 6, 2023
b65affb
Merge pull request #47 from hyperupcall/fix-path-quoting
jwiegley Jan 8, 2023
1b1e1d6
Merge pull request #46 from hyperupcall/fix-logic-errors
jwiegley Jan 8, 2023
9152af8
Merge pull request #45 from hyperupcall/fix-parse-errors
jwiegley Jan 8, 2023
0f27fb8
Merge branch 'master' into fix-deprecations
hyperupcall Jan 14, 2023
ebf8e79
fix: Remove `echo -n` mistake when resolving merge
hyperupcall Jan 14, 2023
371f308
chore: Normalize arguments in shebangs
hyperupcall Jan 14, 2023
352d330
chore: Use `/usr/bin/env bash` for Bash shebang
hyperupcall Jan 14, 2023
59f580c
chore: Add EditorConfig file
hyperupcall Jan 14, 2023
b46924f
Merge pull request #44 from hyperupcall/fix-deprecations
jwiegley Jan 16, 2023
68a5d9e
Merge branch 'master' into improved-shebangs
jwiegley Jan 16, 2023
ee2c386
Merge pull request #48 from hyperupcall/improved-shebangs
jwiegley Jan 16, 2023
dc529e6
Merge pull request #49 from hyperupcall/add-editorconfig
jwiegley Jan 16, 2023
96e66fb
chore: Improve quoting
hyperupcall Jan 22, 2023
7757369
fix: Ensure all shell files are executable
hyperupcall Jan 22, 2023
1997296
Merge pull request #51 from hyperupcall/ensure-is-executables
jwiegley Jan 23, 2023
d57d5fc
Merge pull request #50 from hyperupcall/some-improvements
jwiegley Jan 23, 2023
d35b55e
chore: Improve quoting `read` invocations, and more
hyperupcall Jan 31, 2023
6122bc3
fix: Remove phantom reference to `git-sh-setup` file
hyperupcall Jan 31, 2023
559ad47
Merge pull request #53 from hyperupcall/remove-phantom-file
jwiegley Jan 31, 2023
5b01da5
Merge pull request #52 from hyperupcall/improve-shell
jwiegley Jan 31, 2023
9a2edb0
chore: More Bash improvements
hyperupcall Feb 12, 2023
fd9f3cb
Merge pull request #54 from hyperupcall/bash-improvements
jwiegley Feb 22, 2023
46142a3
Fix stack overflow in git-find script (fixes #3)
jwiegley Aug 22, 2025
1fb42ce
Merge pull request #56 from jwiegley/fix-git-find-stack-overflow
jwiegley Aug 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
root = true

[*]
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.rb]
indent_size = 2

[*.md]
trim_trailing_whitespace = false
2 changes: 1 addition & 1 deletion git-addremove
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

git add -A
git ls-files --deleted -z | while read file; do
git ls-files --deleted -z | while read -r file; do
git rm "$file"
done
4 changes: 2 additions & 2 deletions git-addsub
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# This script makes it much easier to add new submodules

Expand All @@ -12,7 +12,7 @@ for dir in "$@"; do
SUBDIR=$(abspath "$dir")
SUBDIR=$(echo $SUBDIR | sed s/$PROJ_RE//)

repo=$(echo $(grep "url = " "$dir/.git/config") | \
repo=$(grep "url = " "$dir/.git/config" | \
sed 's/.*url = //' | \
sed 's/git@github.com:\([^\/]*\)\//git:\/\/github.com\/\1\//' )

Expand Down
4 changes: 2 additions & 2 deletions git-addtree
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
git subtree add --prefix $1 ext/$(basename $1) master --squash
#!/usr/bin/env bash
git subtree add --prefix "$1" "ext/$(basename "$1")" master --squash
16 changes: 8 additions & 8 deletions git-all-commits
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/bin/sh

find .git/objects -type f | \
while read file; do
if echo $file | egrep -q '\.idx$'; then
git show-index < $file | awk '{print $2}'
elif echo $file | egrep -q '[0-9a-f]{38}$'; then
echo $(basename $(dirname $file))$(basename $file)
while read -r file; do
if echo "$file" | grep -Eq '\.idx$'; then
git show-index < "$file" | awk '{print $2}'
elif echo "$file" | grep -Eq '[0-9a-f]{38}$'; then
echo "$(basename "$(dirname "$file")")$(basename "$file")"
fi
done | \
while read hash; do
if [ "$(git cat-file -t $hash)" = commit ]; then
echo $hash
while read -r hash; do
if [ "$(git cat-file -t "$hash")" = commit ]; then
echo "$hash"
fi
done
8 changes: 4 additions & 4 deletions git-all-objects
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/bin/bash
#!/usr/bin/env bash
set -e
shopt -s nullglob extglob

cd "`git rev-parse --git-path objects`"
cd "$(git rev-parse --git-path objects)"

# packed objects
for p in pack/pack-*([0-9a-f]).idx ; do
git show-index < $p | cut -f 2 -d ' '
git show-index < "$p" | cut -f 2 -d ' '
done

# loose objects
for o in [0-9a-f][0-9a-f]/*([0-9a-f]) ; do
echo ${o/\/}
echo "${o/\/}"
done
8 changes: 8 additions & 0 deletions git-already-merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

# From https://railsware.com/blog/git-housekeeping-tutorial-clean-up-outdated-branches-in-local-and-remote-repositories/

for branch in $(git branch -r --merged | grep -v HEAD)
do
printf '%s\t%s\n' "$(git show --format="%ci %cr %an" "$branch" | head -n 1)" "$branch"
done | sort -r
4 changes: 2 additions & 2 deletions git-amend-all
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
## This is free software, and you are welcome to redistribute it
## under certain conditions; see COPYING for details.

# Purpose: This script adds all modified and deleted files,
# Purpose: This script adds all modified and deleted files,
# except the new files and adds it to the recent commit by amending it

set -e

# User is not in git repository
if ! git branch > /dev/null 2>&1
then
echo "E: '$(basename ${PWD})' - Not a Git repository."
echo "E: '$(basename "${PWD}")' - Not a Git repository."
exit 1
fi

Expand Down
14 changes: 7 additions & 7 deletions git-apply-url
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@

URL=$1

function error {
echo $*
error() {
echo "$*"
exit 1
}

if [[ ! $URL ]]; then
error $0 URL
if [ ! "$URL" ]; then
error "usage: $0 URL"
fi

if [[ -x $(which curl) && $(curl -V | grep https) ]]; then
if command -v curl >/dev/null 2>&1 && curl -V | grep -q https >/dev/null 2>&1; then
fetch="curl -s"
elif [[ -x $(which wget) ]]; then
elif command -v wget >/dev/null 2>&1; then
fetch="wget -O - -q --no-check-certificate"
else
error need curl or wget
fi

$fetch $URL | patch -p1
$fetch "$URL" | patch -p1
2 changes: 1 addition & 1 deletion git-archive-all
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Super basic tool to export repo and all submodules
# as a single zip file
Expand Down
16 changes: 16 additions & 0 deletions git-branch-done
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
# git branch-done <branch>

# destination branch as parameter - depends on merge strategy, typically master
DST_BRANCH=""
if [ -n "$1" ]; then
DST_BRANCH="$1"
else
echo "Usage: git branch-done <branch>"
exit 1
fi

# get current branch - typically topic branch like taskXXXX, bugXXXX, ...
cb=$(git rev-parse --abbrev-ref HEAD)
# no fast forward merge from current branch to destination branch
git checkout "$DST_BRANCH" && git merge --no-ff "$cb" && git branch -d "$cb"
5 changes: 5 additions & 0 deletions git-branch-status-subtree/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*
!gbs-config.sh.inc.example
!git-branch-status
!LICENSE
!README.md
16 changes: 8 additions & 8 deletions git-branch-status-subtree/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ EXAMPLES:
| feature-branch | (even) | (ahead 2) | origin/feature-branch |
| master | (behind 1) | (even) | origin/master |

# compare two arbitrary branches (either local and either remote)
# compare two arbitrary branches - local or remote
$ git-branch-status local-arbitrary-branch fork/arbitrary-branch
| local-arbitrary-branch | (even) | (ahead 1) | fork/arbitrary-branch |
$ git-branch-status fork/arbitrary-branch local-arbitrary-branch
| fork/arbitrary-branch | (behind 1) | (even) | local-arbitrary-branch |

# show all branches - including those synchronized, non-tracking, or not checked-out
# show all branches - local and remote, regardless of state or relationship
$ git-branch-status -a
$ git-branch-status --all
| master | (even) | (ahead 1) | origin/master |
*| master | (even) | (ahead 1) | origin/master |
| tracked-branch | (even) | (even) | origin/tracked-branch |
| (no local) | n/a | n/a | origin/untracked-branch |
| local-branch | n/a | n/a | (no upstream) |
Expand All @@ -77,7 +77,7 @@ EXAMPLES:
# show the current branch
$ git-branch-status -b
$ git-branch-status --branch
| current-branch | (even) | (ahead 2) | origin/current-branch |
*| current-branch | (even) | (ahead 2) | origin/current-branch |

# show a specific branch
$ git-branch-status specific-branch
Expand All @@ -98,7 +98,7 @@ EXAMPLES:
# show all local branches - including those synchronized or non-tracking
$ git-branch-status -l
$ git-branch-status --local
| master | (even) | (ahead 1) | origin/master |
*| master | (even) | (ahead 1) | origin/master |
| tracked-branch | (even) | (even) | origin/tracked-branch |
| local-branch | n/a | n/a | (no upstream) |

Expand All @@ -111,9 +111,9 @@ EXAMPLES:
# show all branches with timestamps (like -a -d)
$ git-branch-status -v
$ git-branch-status --verbose
| 1999-12-31 local | n/a | n/a | (no upstream) |
| 1999-12-31 master | (behind 1) | (even) | 2000-01-01 origin/master |
| 1999-12-31 tracked | (even) | (even) | 2000-01-01 origin/tracked |
| 1999-12-31 master | (behind 1) | (even) | 2000-01-01 origin/master |
| 1999-12-31 tracked | (even) | (even) | 2000-01-01 origin/tracked |
*| 1999-12-31 local-wip | n/a | n/a | (no upstream) |
```


Expand Down
28 changes: 28 additions & 0 deletions git-branch-status-subtree/gbs-config.sh.inc.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
###############################################################################
# optional user-defined config for the 'git-branch-status' program #
#-----------------------------------------------------------------------------#
# * copy this file to: ./gbs-config.sh.inc (or $GBS_CFG_FILE) to customize #
# * the text in this file must be valid BASH #
# * you can also export these configuration options from the environment #
# as well as an alternate location of this file (as $GBS_CFG_FILE) #
# * environment variables will over-ride those defined in this file #
# * environment variables should be named similarly to those in this file #
# with the CFG_* prefix replaced with GBS_* #
# eg: export GBS_CFG_FILE=~/.config/git-branch-status/config.sh.inc #
# eg: export GBS_FETCH_PERIOD=0 #
###############################################################################


# number of minutes between automatic `git fetch --all` calls
# 0 => always, -1 => never (default: -1)
readonly CFG_FETCH_PERIOD=-1


# writable filesystem location for storage of the last-fetch timestamp
# (default: ~/.GBS_LAST_FETCH)
readonly CFG_LAST_FETCH_FILE=~/.GBS_LAST_FETCH


# whether or not to present ANSI colors
# 0 => no, 1 => yes (default: 1)
readonly CFG_USE_ANSI_COLOR=1
Loading