Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Untrack tracked file in Git -- but only in specific branch?

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.

like image 600
wrongusername Avatar asked Feb 20 '12 21:02

wrongusername


People also ask

How do I Untrack a specific file in Git?

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.

How do I Untrack a tracked file?

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.

Is Gitignore tracked?

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. .


1 Answers

git rm --cached projectFile

Will delete the file in the index, so it will no longer be tracked, but won’t physically delete it.

like image 141
poke Avatar answered Oct 23 '22 08:10

poke