Git Add All DOH

Git add -A DOH My recent blogging enironment changes now have me at the terminal alot interacting with git. I quickly noticed it was becoming a pain to do git add folderFileName all the time for each folder file. After doing git add -help it become quite clear I can add everything all at once using git add -A. It is important to note, I consider myself a git newbie. This little trick is likely totally apparent to most git users. To that end, being the admitted newbie I made a mistake. Yes, a big DOH moment! You guess it, I did git add -A and never told git to ignore RedCoth directory. Meaning, all my files and folders I wanted did get added to staging BUT so did all the RedCloth files ( which do NOT need to be under source control ). Of course, after the DOH, flashes of Rob Conery warning me about this very occurance in Tekpub Mastering Git session. Moving on. How is the RedCloth directory and files removed from git local staging?

In this case, I want to remove the folder and all files from the index BUT do not want to remove it from my working directory. I could run git rm folderFileName to remove the index BUT it would also remove the RedCloth folder and files from my working directory which is NOT what I want. Instead, run git rm folderFileName —cached to remove the index and leave the folder and files in the working directory. Now run git status to see that RedCloth directory indeed indicates it can be added to the staging. A git commit -a -m ‘comments’ will now commmit all the folders, files you added with git add -A BUT NOT the RedCloth directory. However, the next time around performing a git add -A will result in adding RedCloth directory again to staging which we do not want. To prevent this, add the RedCloth to your .gitignore file in the root.