Originally, I had everything contained in my master branch.
Then, I decided to split into Mac and Windows branches, and have the master branch only track the source code files. So I began to only stage changes to source code files when in the master branch, and merge those source code changes with the Mac and Windows branches as needed.
Problem is, when I originally tracked everything in my master branch, I had tracked the project file as well. Thus, I would be adding new files to the project and getting it compiling in Mac and Windows, but upon switching back to the master branch, the project file would be switched back to the old version as well, causing compilation to fail.
So how can I stop tracking my project file in the master branch now? I don't want to stop tracking it in my Mac or Windows branches, and I don't want to remove it from earlier versions in the master branch either.
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.
Simply move the files to a folder outside of git, then do "git add .", "git commit". (This removed the files) then add the gitignore, referencing the files/folders, commit again to add the gitignore file to git, then copy/move back in the folders, and they should be ignored.
Ignored files are tracked in a special file named .gitignore that is checked in at the root of your repository. There is no explicit git ignore command: instead the .gitignore file must be edited and committed by hand when you have new files that you wish to ignore. .
git rm --cached projectFile
Will delete the file in the index, so it will no longer be tracked, but won’t physically delete it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With