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:
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
I have never used SVN changelists myself, but if I understand correctly, it allows you to group files into changelists and later separately commit those changelists. (Right?)
I don't think you really need such a feature with Git. You can already separately stage (git add
) each file or parts of it (git add -p
) independently and commit those. You can create branches for each of your changelist, and later merge/rebase those branches. Or you can create several commits and later re-order them with interactive rebase (git rebase -i
).
Instead of svn diff --changelist something
, you will simply use git show changelistbranch
.
You don't have to push those local/temporary branches. Nobody needs to see them, until you consider them ready to be released into the wild.
You can even namespace your "changelist branches": git branch changelist/name_of_your_changelist
, you will then have all changelists grouped by their prefix.
Am I missing something?