unixorn/git-extra-commands

View on GitHub
bin/git-amend-all

Summary

Maintainability
Test Coverage
#!/usr/bin/env bash
## Copyright (C) 2006-2011 Daniel Baumann <daniel.baumann@progress-technologies.net>
##
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
## 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,
# except the new files and adds it to the recent commit by amending them

set -o pipefail
set -e

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

git add . && exec git commit -a --amend -C HEAD