Skip to content

Instantly share code, notes, and snippets.

@nlindley
Created July 16, 2014 23:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nlindley/49f2316d7c7d1de9cc63 to your computer and use it in GitHub Desktop.
Save nlindley/49f2316d7c7d1de9cc63 to your computer and use it in GitHub Desktop.
Script to remove untracked files in a git repository.
#!/bin/bash
git status -su | cut -d' ' -f2- | tr '\n' '\0' | xargs -0 rm
@nlindley
Copy link
Author

To use:

  • Add it somewhere in your $PATH. I have mine in ~/bin.
  • Give executable permission. For example, chmod +x ~/bin/git-rmu
  • From somewhere in your git repository, run git rmu.

If you want the command to be something different, then just rename the file. If you would rather type git removeuntrackedfilesyesiamsure, then rename the file git-removeuntrackedfilesyesiamsure.

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