Untrack files from git temporarily

2019-01-03 07:33发布

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

11条回答
贼婆χ
2楼-- · 2019-01-03 07:42

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

查看更多
Deceive 欺骗
3楼-- · 2019-01-03 07:43

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

查看更多
一纸荒年 Trace。
4楼-- · 2019-01-03 07:45

This worked for me

git reset HEAD 'filename'

查看更多
爷、活的狠高调
5楼-- · 2019-01-03 07:48

to remove untracked files and folders set git clean -fdx

查看更多
何必那么认真
6楼-- · 2019-01-03 08:01

Use following command to untrack files

git rm --cached <file path>
查看更多
Rolldiameter
7楼-- · 2019-01-03 08:02

To remove all Untrack files.Try this terminal command

 git clear -fdx
查看更多
登录 后发表回答