I am learning git, but I am confused by different ways of staging and committing files. To wrap my head around this I’m using a metaphor of directories: working directory, staging directory, commit directory.
- If I
rm
a file from my working directory, it only removes it only from my working directory. It that correct? - If I
git rm
a file from my working directory, it removes it from all three directories. Correct? - If I
git rm --cached
a file, it is removes the file from my staged and commit directories, but leave it in my working directory? - If I have updated, added, and deleted files from my working
directory, and do
git add .
, thengit status
shows staged files that have been added, deleted, and updated. What happens when I commit? Are the deleted files removed from the Commit directory? If I roll back to that commit later, will those deleted files reappear?
Any help to better understand these concepts would be appreciated -thanks!