Just curious if Git has something like Subversions Changelist feature, its something that I find quite handy working with on the fly, I know I could run something like:
cat 'changelistfileimade' | xargs git update
but am curious if there's a built in method too?
I googled around a bit more for this and I think I've found a replacement for the TortoiseSVN ignore-on-commit
changelist use case I mention in my comment above. The command in question is git update-index --assume-unchanged <path/name>
. Git help has this to say about it:
--[no-]assume-unchanged
When these flags are specified, the object names recorded for the paths are not updated. Instead, these options set and unset the "assume unchanged" bit for the paths. When the "assume unchanged" bit is on, Git stops checking the working tree files for possible modifications, so you need to manually unset the bit to tell Git when you change the working tree file. This is sometimes helpful when working with a big project on a filesystem that has very slow lstat(2) system call (e.g. cifs).
This option can be also used as a coarse file-level mechanism to ignore uncommitted changes in tracked files (akin to what .gitignore does for untracked files). Git will fail (gracefully) in case it needs to modify this file in the index e.g. when merging in a commit; thus, in case the assumed-untracked file is changed upstream, you will need to handle the situation manually.
I found an explanation of the option on Nick Quaranto's GitReady blog, which includes the following:
Obviously there’s quite a few caveats that come into play with this. If you
git add
the file directly, it will be added to the index. Merging a commit with this flag on will cause the merge to fail gracefully so you can handle it manually.
But that's only half the battle for me. The next step is knowing what you've ignored (and hopefully remembering why). That was provided by this handy comment by Abe Voelker on an aptly named question. Simply edit your .gitconfig
file with the snippet
[alias]
ignored = !git ls-files -v | grep "^[[:lower:]]"
Don't add the [alias]
bit if it already exists in your file. And now git ignored
will tell you something like this:
h configs/environment/local.php
h configs/logging/log4php.xml
You can take this a step further with aliases for ignore
and unignore
with the following lines:
ignore = update-index --assume-unchanged
unignore = update-index --no-assume-unchanged
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With