Mau*_*ert 102 git xcode gitignore
我希望git忽略我的UserInterfaceState.xcuserstate
XCode4项目中的文件,但是我应该把.gitignore
文件放在哪里?,它是否在.git
文件夹中?还是出去?该.git
是在同一文件夹与ProjectName.xcodeproj
文件
Dan*_*iro 124
您可以.gitignore
在项目的每个目录中拥有一个.
但是,最佳做法是.gitignore
在项目根目录中包含一个文件,并将要忽略的所有文件放在其中,如下所示:
ignoredFile.whatever
ignoredDirectory/*
directory/ignoredFileInsideDirectory
.svn
Run Code Online (Sandbox Code Playgroud)
创建.gitignore
文件后,对存储库进行更改或更新的忽略文件将不会显示为等待提交.
您还可以拥有一个全局本地git ignore文件,它将管理您的所有git存储库.
git config --global core.excludesfile ~/.gitignore_global
对于与项目无关的忽略文件,例如IDE相关文件等,此替代方案尤其有用.
Kha*_*lla 21
There are there approaches to ignore files in git:
~/.gitignore_global
path. This approach good if you want to exclude some type files which is generated by OS or any other logging, cashing and etc. tools..git/info/exclude
file in your repository. The rules specified under this file will not be
committed, which means it will not be shared with others. Generally this approach useful to prevent committing of locally generated files. For example, for files created by your editor..gitignore
in any sub path of your specific repository. This approach usually used to ignore some types of file only under specific folder of specific repository. While this files can be added to version controlling by other paths and other repositories.So, My suggest to you is, if you want to ignore your specific file (UserInterfaceState.xcuserstate
) in your all repositories the best approach is to use global git ignore approach. However if your file is generated only in specific repository you can use per-repository git ignore approach.
For more information you can read this great blog post. And there per language specific git ignore rules can be founded here. And you can auto generate general git ignore rules for specific language, tool or os using this web site.
Von*_*onC 12
我应该把
.gitignore
文件放在哪里?,它在.git文件夹中吗?
文件夹.gitignore
里面没有.git
.
但是.git/info/exclude
,它是一个文件,允许您在本地排除文件,通常当您只想为此特定仓库排除文件时(使用类似这样的别名):
git config alias.exclude "!sh -c 'echo \"$1\" >> .git/info/exclude' -"
git exclude UserInterfaceState.xcuserstate
Run Code Online (Sandbox Code Playgroud)
如果您需要为所有类似的项目排除此文件,如他在答案中提到的Elnur Abdurrakhimov,则将其全局排除.
echo UserInterfaceState.xcuserstate >> ~/.gitignore
Run Code Online (Sandbox Code Playgroud)
但是,正如" 我们需要检入*.xcuserstate吗? "中提到的那样,如果它是一种应该被该repo的任何用户忽略的文件类型,我实际上会在repo的顶部版本化一个.gitignore,内容类似于:
*.xcuserstate
Run Code Online (Sandbox Code Playgroud)
这样,该repo的任何用户都不会意识到该文件存在并生成(无论其名称是什么):它永远不会出现git status
.
或者你可以完全忽略xcuserdata/
(无论是全局的.gitignore
,还是版本的,如通用的GitHubObjective-C.gitignore
文件.
你应该不把特定工具的文件到项目的.gitignore
文件-除非需要该工具由项目的每个开发人员使用.
而是.gitignore
在您的主目录中创建您的个人全局文件并将其激活:
git config --global core.excludesfile ~/.gitignore
Run Code Online (Sandbox Code Playgroud)
现在,您可以将开发工具生成的任何文件放入.gitignore
文件中.
归档时间: |
|
查看次数: |
53932 次 |
最近记录: |