π π» π
Ever so often, I like to "plunge" (more on that later..) into the depths of Git deeper to strengthen my understanding of this tool I leverage every single day.
Recently, I wanted to untrack files that had previously been tracked and ultimately were pushed to my remote repository.
I added the directory for said files to my .gitignore and believed my next step would be to just delete them off the remote directly on GitHub... But, it occurred to me there were probably better ways to achieve this same outcome.
(scroll down to theπfor tl;dr)
My investigating lead me to a few places:
1. Super-User Forum Comment on --cached
- Here is where I learned about
git rm --cached...
. - What
--cached
does is:
"Use this option to unstage and remove paths only from the INDEX. Working tree files, whether modified or not, will be left alone."
[emphasis mine] [source below]
2. Git Documentation on git rm
- This lead me further into this "pipe" (more still to come...) with asking myself "what is the git index?"
3. SO forum comment on the actual /.git/index
- Where I learned that:
"The index is a single, large, binary file in /.git/index, which lists all files in the current branch, their sha1 checksums, time stamps and the file name -- it is not another directory with a copy of files in it."
Moreover, the git "index" is where your changes go when you run git add ...
and directly into that above mentioned binary (/.git/index
) which acts as your "staging area" in between your workspace (working directory) and your local repository (where your changes go to your current branch when you run git commit ...
).
π
To summarize, when you run git rm --cached folder/\*
git will delete the (history?) data represented by this directory in your /.git/index binary/staging area. Next, you push these changes to your remote to have them scrubbed out, LEAVING your directory locally. If this directory has been added to your .gitignore, it will no longer be tracked as well.
π½ π πββοΈ
Now for the conceit that git uses regarding the words "plunge", "pipe" and these π emojis I've been cheekily trying to breadcrumb into this post...
Through my investigation I learned of the "high level" and "low level" conceit that git adopts: "Porcelain" (high) and "Plumbing" (low).
4.a. high_level_commands_porcelain
4.b. low_level_commands_plumbing
Anyway, just thought that was funny. Git uses a toilet metaphor in their documentation... π
Top comments (0)