Skip to content

Instantly share code, notes, and snippets.

@stephanb
Last active August 29, 2015 14:10
Show Gist options
  • Save stephanb/5f83e2f3af6edc409ec0 to your computer and use it in GitHub Desktop.
Save stephanb/5f83e2f3af6edc409ec0 to your computer and use it in GitHub Desktop.
Git: add all modified files to the index; delete all removed files from the index
git add $(git status | grep "modified:" | cut -d " " -f 4)
git rm $(git status | grep "deleted:" | cut -d " " -f 5)
@stephanb
Copy link
Author

stephanb commented Dec 2, 2014

If you're presented with a long list of modified and deleted files in your Git repository, e.g. after a version update, you might find the commands above handy. They split all lines from git status containing modified: or deleted: by single space characters (cut -d " ") and pass the 4th/the 5th field (-f 4, -f 5) to git add/git rm.

If there's still a long list of untracked files after that, it's probably as easy as git add . to add them to the index. Don't forget to git push after all ;)

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