Skip to content

Instantly share code, notes, and snippets.

@kryten87
Last active May 3, 2018 21:24
Show Gist options
  • Save kryten87/041b66df532f76fb05936e920db07f78 to your computer and use it in GitHub Desktop.
Save kryten87/041b66df532f76fb05936e920db07f78 to your computer and use it in GitHub Desktop.
A simple bash function which shows files changes since a specific commit or branch
# paste this into your shell alias file
#
# Usage:
# gitchgs # show all files changed from develop branch
#
# gitchgs a1b2c3d4 # show all files changed since commit a1b2c3d4
#
# gitchgs some-branch # show all files changed between branch some-branch and HEAD
#
gitchgs () {
# get the branch from which you want the diff
#
local branch=$1
# is the branch null/empty? if so, subsitute the default "develop" branch
#
if [ -z "$branch" ]; then
branch="develop"
fi
# show a git diff with filenames only, and showing only modified files (ie.
# omit deleted files) between $branch and HEAD
#
git diff --diff-filter=ACMR --name-only $branch..HEAD
}
@kryten87
Copy link
Author

kryten87 commented May 2, 2018

I use this shortcut constantly. For example, when I'm about to merge a branch with develop (I use git flow), I will run:

gitchgs | xargs atom

which will open all of the files which have changed in the feature branch in atom (my editor of choice). I then review each of the files before finishing the branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment