Skip to content

Instantly share code, notes, and snippets.

@jperocho
Last active September 14, 2018 20:03
Show Gist options
  • Save jperocho/59c0cb5632f4539a3dc3e3fe3db4ccd3 to your computer and use it in GitHub Desktop.
Save jperocho/59c0cb5632f4539a3dc3e3fe3db4ccd3 to your computer and use it in GitHub Desktop.
Git helpful Commands

To assume unchange

git update-index --assume-unchanged -- <file>

To revert back

git update-index --no-assume-unchanged <file>

To list all marked as assume-unchanged

git ls-files -v | grep "^[a-z]"

Removing files to repo

git filter-branch --tree-filter 'rm -rf <file>' HEAD

Removing node_modules to git permanently

add 'node_modules' to .gitignore file

git rm -r --cached node_modules
git commit -m 'Removed node_modules, ignored node_modules'
git push origin master

Counting files and lines of code

git diff --shortstat `git hash-object -t tree /dev/null`

Adding changes to current commit

*Note: Use this only if branch is not yet pushed to origin

git commit -a --amend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment