Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Naive Git setup, Is it possible to untrack files which are listed on my .gitignore?

I have made a naive mistake while setting up my project. We are 3 developers working on one remote repository. While setting up git we never thought that Xcode would produce non-development files and push them to our remote repo. Now once I learnt after crash and burn I made a .gitignore file.

.gitignore looks like this, please do let me know if I should edit this too. (File credit goes too : This question's answer given by Abizem)

# Mac OS X
*.DS_Store

# Xcode
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
*.xcuserstate
project.xcworkspace/
xcuserdata/

But now question is there any possibilities that I can untrack all of those listed files from our source control?

or

Can I list all tracked files with their path and later I know a painful way to remove one by one with,

git rm --cached 'file path'
like image 265
TeaCupApp Avatar asked Jan 31 '12 00:01

TeaCupApp


People also ask

How do you remove files that are listed in the .gitignore but still on the repository?

gitignore are not being tracked, you can use the git clean command to recursively remove files that are not under version control. Use git clean -xdn to perform a dry run and see what will be removed. Then use git clean -xdf to execute it. Basically, git clean -h or man git-clean (in unix) will give you help.


1 Answers

Something I've done a few times in these situations, is move all of the files in the repository somewhere else on the filesystem (except .gitignore), then run:

git add --all
git commit -m "Remove all files"

Then add your files back in and run the following:

git add --all
git commit -m "Re-add files"

This second add & commit will adhere to your gitignore file.

like image 63
Ell Neal Avatar answered Sep 27 '22 17:09

Ell Neal