Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Untrack files from git temporarily

I have setup a local git on my machine. When I initialized git, I added pre-compiled libs and binaries. However, now during my development I don't want to check in those files intermittently. I dont want to remove these files from repo. Is there any way to not keep a track of these files till I complete my development. (I think I can not use .gitignore as it works only for those files which are not in git. I want to temporarily disable tracking of files.)

like image 712
agent.smith Avatar asked Aug 06 '11 02:08

agent.smith


People also ask

How do I Untrack a 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 remove files from git cache?

Usually, you want to clear your Git cache because you added new entries in your gitignore files and you want them to be taken into account. The easiest way to clear your Git cache is to use the “git rm” command with the “–cached” option. You can choose to remove one file or to remove an entire working directory.

How do I remove a file from git?

The git rm command can be used to remove individual files or a collection of files. The primary function of git rm is to remove tracked files from the Git index. Additionally, git rm can be used to remove files from both the staging index and the working directory.


2 Answers

git update-index should do what you want

This will tell git you want to start ignoring the changes to the file
git update-index --assume-unchanged path/to/file

When you want to start keeping track again
git update-index --no-assume-unchanged path/to/file

Github Documentation: update-index

like image 82
Andy Avatar answered Oct 08 '22 06:10

Andy


you could keep your files untracked after

git rm -r --cached <file> 

add your files with

git add -u 

them push or do whatever you want.

like image 45
cajuuh Avatar answered Oct 08 '22 04:10

cajuuh