Skip to content

Instantly share code, notes, and snippets.

@stevewithington
Last active June 3, 2019 15:07
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 stevewithington/52f0e13024eea79df4b7db5c9bb2c363 to your computer and use it in GitHub Desktop.
Save stevewithington/52f0e13024eea79df4b7db5c9bb2c363 to your computer and use it in GitHub Desktop.
Useful Git Commands I Don't Use Every Day

Useful Git Commands I Don't Use Every Day

Get the Size of a Git Repo, Excluding Ignored Files

git count-objects -vH

Produces something similar to:

count: 2717
size: 1.00 MiB
in-pack: 9740
packs: 1
size-pack: 7.98 GiB
prune-packable: 0
garbage: 0
size-garbage: 0 bytes

Untrack files already added to Git repo based on .gitignore

  1. Commit changes before proceeding, including the .gitinore file

  2. If you only want to remove a few files, you can use the following command and it will only remove the file from Git's index, and keep it on your filesystem.

git rm --cached someFile.ext
  1. If you have a ton of files to remove (e.g., an entire directory, etc.), you can remove everything from the repo, but only from Git's index, not the actual file:
git rm -r --cached .
  1. If you removed everything in Step 3, then you'll want to re-add everyting
git add .
  1. Commit & Push Your Changes
git commit -m 'remove ignored files from repo'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment