search

Home  >  Q&A  >  body text

How to cancel tracking of a file in GIt

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?

我想大声告诉你我想大声告诉你2757 days ago952

reply all(4)I'll reply

  • 给我你的怀抱

    给我你的怀抱2017-05-17 10:04:56

    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.

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-17 10:04:56

    git update-index –assume-unchanged file_path 
    
    • file_path absolute path

    reply
    0
  • 为情所困

    为情所困2017-05-17 10:04:56

    The question described by the question is not very clear, so I will answer it based on various situations:

    1. Do not track files that are not tracked by git
      Just add the file to the .gitignorefile

    2. Stop tracking files tracked by git, but keep the previous tracking status of the file
      git rm --cached 文件名

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

    reply
    0
  • 迷茫

    迷茫2017-05-17 10:04:56

    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

    reply
    0
  • Cancelreply