I don’t want Git to track disimportant this file. I can create a .gitignore file to untrack it, but is there any command that can achieve better results?
git is not tracking this file. It's telling you this. If you don't want it to pay attention to this file, just add .gitignore.
If you plan to share the warehouse with others, but don’t want others to ignore this file or know the name of this file, you can write it in the .git/info/exclude file.
Extended reading: ProGit Second Edition Chinese Version.
You don’t want others to use this file. Why do you put it in the git directory?
If you want others to use it or this file is needed in the project, a better approach is to make a disimportant.example file, delete the disimportant file, and then indicate this in the project description
git is not tracking this file. It's telling you this. If you don't want it to pay attention to this file, just add .gitignore.
If you plan to share the warehouse with others, but don’t want others to ignore this file or know the name of this file, you can write it in the .git/info/exclude file.
Extended reading: ProGit Second Edition Chinese Version.
file_path absolute path
The question described by the question is not very clear, so I will answer it based on various situations:
Do not track files that are not tracked by git
Just add the file to the
.gitignore
fileStop tracking files tracked by git, but keep the previous tracking status of the file
git rm --cached 文件名
Temporarily make git ignore tracked files
git update-index --assume-unchanged 文件名
For a detailed explanation of this command, please see the high-voted answer of git ignores files that have been submitted
You don’t want others to use this file. Why do you put it in the git directory?
If you want others to use it or this file is needed in the project, a better approach is to make a disimportant.example file, delete the disimportant file, and then indicate this in the project description