简体   繁体   English

如何清除git的未跟踪文件列表?

[英]How can I clear the list of untracked files of git?

I have to you use git for a university project. 我必须为您的大学项目使用git。 Unfortunately I had no previous experience with it and I think I kinda messed things up. 不幸的是,我以前没有经验,所以我觉得有些混乱。

As far as I understand: 据我所理解:

git status

lists all files that are different from what I committed and also all untracked files, that are not tracked, whatever this means. 列出所有与我提交的文件不同的文件,以及所有未跟踪的,未跟踪的文件,无论这意味着什么。

I want to change a branch, but git wants me to delete/move a file called .DS_Store, I saw that this file is listed in my untracked files. 我想更改一个分支,但是git要我删除/移动一个名为.DS_Store的文件,我看到此文件在我的未跟踪文件中列出。

I've seen in other questions that there are numerous ways to delete untracked files. 在其他问题中,我看到有很多删除未跟踪文件的方法。 Unfortunately about every folder on my hard drive seems to be listed in those untracked files what seems very wrong to me. 不幸的是,我硬盘上的每个文件夹似乎都被列出在那些未跟踪的文件中,这对我来说似乎很不对劲。

Please explain me in a nutshell what untracked files are and more importantly if there is a way that git forgets about them. 请简而言之,向我解释什么是未跟踪的文件,更重要的是,如果git有办法忘记它们。 Such I'd could start from scratch. 这样我可能会从头开始。

In a nutshell, untracked files are files that you haven't told git to start tracking so they are not part of the previous revision (in which case git would tell you if they have been deleted, modified, etc) and they haven't been added to the index either (in which case git would tell you they were added). 简而言之,未跟踪的文件是您没有告诉git开始跟踪的文件,因此它们不属于以前的版本(在这种情况下git会告诉您是否已删除,修改等),并且它们没有被添加到索引中(在这种情况下,git会告诉您它们已被添加)。 If you want a number of files to not be considered for version control (there are many cases of this situation, the most common for development is: binaries that are produced from the source you are tracking under version control) then the simplest way to do it is by using .gitignore to tell git what files or directories to not care for (as an additional item I'll warn you that it works only for files that haven't been added yet to the project.... so if you want to start ignoring a file that is already part of the the last revision, you will probably have to go back in history and rewrite it so the file is not part of the history of the project). 如果您不希望将多个文件用于版本控制(这种情况有很多情况,最常见的开发是:在版本控制下从要跟踪的源生成的二进制文件),那么最简单的方法是它是通过使用的.gitignore告诉混帐什么文件或目录不关心(作为一个额外的项目,我会提醒你,它仅适用于那些尚未添加到项目中的文件....所以,如果你想要开始忽略上一个修订版本中已经存在的文件,您可能必须返回历史记录并将其重写,以使该文件不属于项目历史记录。

Just create file ~/.gitignore_global and paste there this content : 只需创建文件~/.gitignore_global然后粘贴以下内容即可

# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## Build generated
build/
DerivedData/

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/

## Other
*.moved-aside
*.xccheckout
*.xcscmblueprint

or this (looks better) 或者这个(看起来更好)

# Xcode
.DS_Store
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
*.xcworkspace
!default.xcworkspace
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
# Pods - for those of you who use CocoaPods
Pods

Or combine those two. 或将两者结合。

I just googled "Xcode gitignore" 只是用谷歌搜索“ Xcode gitignore”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM