Last active
February 12, 2019 21:47
-
-
Save danielbdias/82d3e2d4e2165d9026501eae9d903722 to your computer and use it in GitHub Desktop.
Listing files that you changed in your current branch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# put here your main branch | |
MAIN_BRANCH=master | |
# command to list the files that you changed in your current branch and already commit to that branch | |
git --no-pager diff --name-only $MAIN_BRANCH | |
# and command to list the files that you changing right now | |
git status -s | awk '{if ($1 == "M" || $1 == "??") print $2}' | |
# execute both commands, concatenate the results and remove the duplicates | |
( git --no-pager diff --name-only $MAIN_BRANCH; git status -s | awk '{if ($1 == "M" || $1 == "??") print $2}' ) | sort -u | |
# extra: to pass this files to a command line executable (like RSpec, Reek or Rubocop) | |
( git --no-pager diff --name-only $MAIN_BRANCH; git status -s | awk '{if ($1 == "M" || $1 == "??") print $2}' ) | sort -u | grep .rb$ | tr '\n' ' ' | xargs bundle exec rubocop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm using these commands when I need to test / lint in a large codebase, where the procedures take much time to run.