Last active
December 11, 2015 17:18
-
-
Save 7ochem/4633438 to your computer and use it in GitHub Desktop.
Different shell command to mass add files to your git commit
This file contains 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
# This is the base of the commands below. This adds all files appearing in git status: | |
git status -s |grep -E "^.[^D] " |sed "s/^.. //" |xargs git add | |
git status -s |grep -E "^.D " |sed "s/^.. //" |xargs git rm | wc -l | |
# For a simple add all (no deletions) you probably want to use this | |
# (add all files * and all dot files .[!.]*, asterix won't match dot files): | |
git add * .[!.]* | |
# These commands rely on the short GIT status output "git status -s" | |
# Short status line syntax is "XY myfile" | |
# X (first char) displays the status for a file in the staging area | |
# Y (second char) displays the status for a file in the working directory | |
# Add all but untracked files | |
git status -s |grep -E "^[^\?][^D] " |sed "s/^.. //" |xargs git add | |
git status -s |grep -E "^[^\?]D " |sed "s/^.. //" |xargs git rm | wc -l | |
# Unstage all staged files | |
git status -s |grep -E "^[^ ]. " |sed "s/^.. //" |xargs git reset HEAD | |
# There's more to come ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment