Useful git tips
This is a collection of useful git commands, aliases, tips and tricks that I’ve come across or been using. Feel free to contribute to this collection by adding a comment below.
Aliases for ignoring files
To prevent changes in already-commited files from being commited, you can update your index with the
--assume-unchaged flag for the files that you don’t want to commit. Here are a couple of useful aliases for dealing with this.
ignore = !git update-index --assume-unchanged unignore = !git update-index --no-assume-unchanged ignored = !git ls-files -v | grep ^[a-z]
With these aliases you can use
git ignore <file> to ignore a file,
git unignore <file> to unignore a file, and
git ignored to list files that are currently being ignored.
Warning: Adding a file directly with
git add <file> will add the file regardless of this flag.
Source: http://gitready.com/intermediate/2009/02/18/temporarily-ignoring-files.html (comments)
Commit partial changes
If you want to only commit certain changes in a file, you can use the following command:
git add -p <files>
August 9, 2015