Skip to content

Commit d49c4e7

Browse files
committed
Add git-amend-all script
Signed-off-by: Joe Block <jpb@unixorn.net>
1 parent 0e37b12 commit d49c4e7

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ If you wrote one of these scripts and want it removed from this collection, plea
4747
| ------ | --------------- | ----------- |
4848
| `git-add-username-remote` | Ryan Tomayko's dotfiles | Adds a remote for the current repository for the given GitHub username. |
4949
| `git-age` | Kristoffer Gronlund's [wiki](https://github.com/krig/git-age/wiki) | A git-blame viewer, written using PyGTK.|
50+
| `git-amend-all` | John Wiegley's [git scripts](https://github.com/jwiegley/git-scripts) | Adds all modified and deleted files, except the new files and adds them to the recent commit by amending it |
5051
| `git-attic` | Leah Neukirchen's [blog](https://leahneukirchen.org/blog/archive/2013/01/a-grab-bag-of-git-tricks.html) | Displays a list of deleted files in your repository. 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. |
5152
| `git-authors` | Michael Markert's [dotfiles](https://github.com/cofi/dotfiles) (as `git-changes`) | List authors in the repository in descending commit-count order. |
5253
| `git-big-file` | Mislav Marohnić's [dotfiles](https://github.com/mislav/dotfiles) | Show files in the repository larger than a threshold size. |

bin/git-amend-all

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
## Copyright (C) 2006-2011 Daniel Baumann <daniel.baumann@progress-technologies.net>
3+
##
4+
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
5+
## This is free software, and you are welcome to redistribute it
6+
## under certain conditions; see COPYING for details.
7+
8+
# Purpose: This script adds all modified and deleted files,
9+
# except the new files and adds it to the recent commit by amending them
10+
11+
set -o pipefail
12+
set -e
13+
14+
# User is not in git repository
15+
if ! git branch > /dev/null 2>&1
16+
then
17+
echo "E: '$(basename ${PWD})' - Not a Git repository."
18+
exit 1
19+
fi
20+
21+
git add . && exec git commit -a --amend -C HEAD

0 commit comments

Comments
 (0)