difference between git ignore and untrack

后端 未结 3 1699
我在风中等你
我在风中等你 2021-02-04 00:03

What\'s the difference between ignore a folder and untrack in git? I need to remove some folders from my git repository and I am working in Netbeans with the git plugins and put

相关标签:
3条回答
  • 2021-02-04 00:45

    You will want to use untrack instead of gitignore as gitignore won't affect files that are currently being tracked. http://git-scm.com/docs/gitignore

    0 讨论(0)
  • 2021-02-04 00:54

    By "ignore" I assume you mean .gitignore, which is a special file you can make that git will read to determine a set of files and/or directories to ignore. You can override this, but generally these files will be hidden from any git operation.

    "Untracked" in git just means that you haven't added the file to the repository yet.

    If a file is untracked and excluded by the .gitignore, you won't even see it via git status or any other git command.

    To solve your current problem, where you have already accidentally added files that you do not want to track and want to ignore, first add those folders to your .gitignore and then try this command:

    git rm -r --cached "path/to/ignored/directories"
    

    This will remove the undesired directories from your repo but will not delete them from your local working copy.

    0 讨论(0)
  • 2021-02-04 00:58

    If you create a file in your repository named .gitignore, git will use its rules when looking at files to commit. git will not ignore a file that was already tracked (i.e. was in the repo) before a rule was added to this file to ignore it. File must be un-tracked (removed from the repo) using

    git rm --cached filename
    

    The command will stop tracking but keep the file there intact.

    0 讨论(0)
提交回复
热议问题