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)

  • git rerere does not auto-commit autoupdated merge resolutions
  • How to add git repo to working dir of a project
  • How to recover commit from 'detached head state'?
  • Update the fork Github
  • git2r::summary() produces different results when called from console and by RStudio
  • git cherry-pick -x: link in details instead of in summary
  • # 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'
    

  • Jenkins + git - ensure that the build has been run
  • Maintaining 3rd Party Django Apps as Git submodules
  • Git gives me a “Permission Denied” error when writing files that I am pulling
  • Git push error: “origin does not appear to be a git repository”
  • Safe master-master setup with git? (writable git mirror)
  • git workflow: Can I prevent a certain file from being merged to another branch but still keep it under version control?
  • One Solution collect form web for “Naive Git setup, Is it possible to untrack files which are listed on my .gitignore?”

    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.

    Git Baby is a git and github fan, let's start git clone.