What git add does


I’ve used git on a few small projects now—not real work, just quick scripts for things—and so far I’ve mostly treated it like Subversion. I knew about the staging area, but it was a little blurry, and the need to type commit -a on files I’d already added was just a speck of annoyance. But suddenly it struck me that git’s add is completely different from svn’s add. On svn, add puts your file under version control. On git, add promotes your file (whether new, changed, or deleted) to the staging area. This distinction is somewhat obscured by commit -a, which only operates on files that have at least one commit—or, it might seem, on files that are not yet under version control because you’ve never used add on them.

I’m sure this note is no news to regular git users, and maybe it’s incomprehensible to others, but for me it’s one of those minor epiphanies, and I thought I’d document it for a change.

blog comments powered by Disqus Prev: STARTTLS Problems with Ruby Next: jQuery-UI Linked Sliders