Zlatko Đurić


Git and three copies of a file

I ran into git ls-files today, which I don’t normally use, and one of the top search results led me to this stackoverflow answer. It is very useful, so I’ll make note to myself, to try and remember it this time.

So, you checkout a file, so your repo index.html, your index.html and worktree index.html are all the same. Then you change the file, so your repo and index are the same, but the worktree file is different. Then you e.g. git add it, and now your repo differs from index and worktree. Or e.g. you make a further edit, so now all three of them are different copies.