Why are there two ways to unstage a file in Git?

Sometimes git suggests git rm –cached to unstage a file, sometimes git reset HEAD file. When should I use which? EDIT: D:\code\gt2>git init Initialized empty Git repository in D:/code/gt2/.git/ D:\code\gt2>touch a D:\code\gt2>git status # On branch master # # Initial commit # # Untracked files: # (use “git add <file>…” to include in what will … Read more

Removing multiple files from a Git repo that have already been deleted from disk

I have a Git repo that I have deleted four files from using rm (not git rm), and my Git status looks like this: # deleted: file1.txt # deleted: file2.txt # deleted: file3.txt # deleted: file4.txt How do I remove these files from Git without having to manually go through and add each file like … Read more

Ignore files that have already been committed to a Git repository [duplicate]

This question already has answers here: How can I make Git “forget” about a file that was tracked, but is now in .gitignore? (31 answers) Closed 4 years ago. I have an already initialized Git repository that I added a .gitignore file to. How can I refresh the file index so the files I want … Read more

Remove a file from a Git repository without deleting it from the local filesystem

My initial commit contained some log files. I’ve added *log to my .gitignore, and now I want to remove the log files from my repository. git rm mylogfile.log will remove a file from the repository, but will also remove it from the local file system. How can I remove this file from the repo without … Read more