Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove duplicate file tracking in Git

Tags:

git

github

One of my files is tracked twice after I changed the name of my folder.

Git is now tracking the following two files, which are actually the same file.

src/Website/scripts/common.js

src/Website/Scripts/common.js

How can I remove the second one from be tracked? This folder doesn't excist anymore, because I renamed it from Scripts to scripts.

like image 388
Marco Avatar asked Aug 03 '11 14:08

Marco


People also ask

How do I remove a file from a Git track?

Removing Files To remove a file from Git, you have to remove it from your tracked files (more accurately, remove it from your staging area) and then commit. The git rm command does that, and also removes the file from your working directory so you don't see it as an untracked file the next time around.

What does Git rm -- cached do?

The Git rm –cached flag removes a file from the staging area. The files from the working directory will remain intact. This means that you'll still have a copy of the file locally. The file will be removed from the index tracking your Git project.


1 Answers

git rm --cached /src/Website/Scripts/common.js
git commit

--cached makes git refer to the versioned state, rather than the working tree.

like image 163
shelhamer Avatar answered Oct 19 '22 14:10

shelhamer