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.)
9 Solutions collect form web for “Untrack files from git temporarily”
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
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.
git rm --cached
However, you shouldn’t be committing compiled binaries and external dependancies in the first place. Use a tool like Bundler to pull those in instead.
Use following command to untrack files
git rm --cached <file path>
The git-book mentions this in section 2.4: “Undoing Things”. Basically, what you have to do is reset the state of the index for some files back to the HEAD state, that is to the state of the latest checkout (or commit). This undoes staging the file to the current index. The command for this task is
So, the command you have to execute is:
git reset HEAD /path/to/file
The newer versions of git (I believe since 1.6 or so) gives this command (and many more) as a tip when executing
git status. These versions are very user-friendly. A personal tip: if you are only staging a few files, use
git add -i. This will launch the interactive staging tool, which makes thing particularly easy. Also, I highly recommend reading the book, as it is very explicit on the use of git in practical situations.
I am assuming that you are asking how to remove ALL the files in the build folder or the bin folder, Rather than selecting each files separately.
You can use this command:
git rm -r -f /build\*
Make sure that you are in the parent directory of the build directory.
This command will, recursively “delete” all the files which are in the bin/ or build/ folders. By the word delete I mean that git will pretend that those files are “deleted” and those files will not be tracked. The git really marks those files to be in delete mode.
Do make sure that you have your .gitignore ready for upcoming commits.
Documentation : git rm
Not an answer to the original question. But this might help someone.
To see the changes you have done (know which files are marked as –assume-unchanged)
git ls-files -v
The resulted list of files will have a prefix with one character (ex : H or h)
If it is a lowercase (i.e. h) then the file was marked –assume-unchanged
git reset [file]
Get file back from staging area to working directory
I often forget to add my node modules to the .gitignore file, this solves that problem.
To remove all Untrack files.Try this terminal command
git clear -fdx