[英]How can i stop git from tracking a folder?
i got a short problem with git.我遇到了 git 的一个小问题。 I found out that git is like tracking my C:\Users\name folder, where name is a placeholder.
我发现 git 就像跟踪我的 C:\Users\name 文件夹,其中 name 是占位符。 Because when i am at C:\Users\name and say git status it tells me: '''untracked files [...] nothing added to commit but untracked files present (use "git add" to track) ''' How can i say git that it should not track my users folder?
因为当我在 C:\Users\name 并说 git 状态时,它告诉我:'''未跟踪的文件 [...] 没有添加到提交但未跟踪的文件存在(使用“git add”跟踪)'''如何我可以说 git 它不应该跟踪我的用户文件夹吗? I read something about.gitignore, but i think this is not working, because i dont want to whole folder to be tracked from git.
我读了一些关于.gitignore 的内容,但我认为这不起作用,因为我不想从 git 跟踪整个文件夹。
If git
is trying to track your user folder it means that the root of the ropository is in location which has your user folder as its subirectory.如果
git
正在尝试跟踪您的用户文件夹,则意味着存储库的根目录位于以您的用户文件夹为其子目录的位置。 This could be C:\Users
or C:\
.这可能是
C:\Users
或C:\
。
You need to copy your repository to a dedicated folder eg C:\git\Project1
.您需要将存储库复制到专用文件夹,例如
C:\git\Project1
。 Please be aware that if you are moving files, you need to move the hidden .git
folder.请注意,如果您要移动文件,则需要移动隐藏的
.git
文件夹。 ( .git
folder makes a folder a git reposiotry). (
.git
文件夹使文件夹成为 git 存储库)。
If you're confused, it may be easiest to start in a new folder.如果您感到困惑,从新文件夹开始可能是最简单的方法。
git
git
中的文件夹You can use a .gitignore
file.您可以使用
.gitignore
文件。
gitignore - Specifies intentionally untracked files to ignore
gitignore - 指定有意忽略的未跟踪文件
To ignore a folder use dir_to_ignore/
要忽略文件夹,请使用
dir_to_ignore/
Please note that .gitignore
should be part of the repository.请注意
.gitignore
应该是存储库的一部分。
.gitignore
at the root of the repository.gitignore
的文本文件folder_to_ignore/
to it (please note the slash at the end.folder_to_ignore/
到它(请注意最后的斜线。git add.gitignore
git commit 'Adding.gitignore'
Solved it by deleting the.git Folder.通过删除.git文件夹解决了这个问题。 But the folder was hidden and therefore in havent seem it
但是该文件夹被隐藏了,因此似乎没有
In addition to tymtam's answer, I want to add that if the git is already tracking the directory, adding the.gitignor file will not help and you should use the "git rm" command so that the git stops tracking the file or directory.除了 tymtam 的回答,我想补充一点,如果 git 已经在跟踪目录,添加 .gitignor 文件将无济于事,您应该使用“git rm”命令,以便 git 停止跟踪文件或目录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.