I want git to ignore my UserInterfaceState.xcuserstate
file in my XCode4 project, but where should I put the .gitignore
file?, is it inside the .git
folder? or out? The .git
is in same folder with the ProjectName.xcodeproj
file
相关问题
- Xcode debugger displays incorrect values for varia
- Why does recursive submodule update from github fa
- Image loads in simulator but not device?
- Extended message for commit via Visual Studio Code
- Emacs shell: save commit message
相关文章
- 请教Git如何克隆本地库?
- xcode 4 garbage collection removed?
- Xcode: Is there a way to change line spacing (UI L
- Unable to process app at this time due to a genera
- Popover segue to static cell UITableView causes co
- “Storyboard.storyboard” could not be opened
- didBeginContact:(SKPhysicsContact *)contact not in
- GitHub:Enterprise post-receive hook
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.
typically, its best practice to include the
.gitignore
file in the project's root directoryThere is no
.gitignore
inside a.git
folder.The is however a
.git/info/exclude
file, which allows you to exclude a file locally, generally when you want to exclude a file only for this specific repo (with an alias like this one):If you need to exclude this file for all similar project, as Elnur Abdurrakhimov mentioned in his answer, exclude it globally.
But, as mentioned in "Do we need to check in *.xcuserstate?", if it is a type of file which should be ignored by any user of that repo, I would actually version a .gitignore at the top of the repo, with a content similar to:
That way, any user of that repo won't even realize that this file exists and is generated (whatever its name is): it won't show up in a
git status
ever.Or you can ignore
xcuserdata/
entirely (either in a global.gitignore
, or in a versioned one, like the generic GitHubObjective-C.gitignore
file.You should put the .gitignore file into the project root directory.
You should not put tool-specific files into a project's
.gitignore
file — unless that tool is required to be used by each developer of the project.Instead, create your personal global
.gitignore
file in your home directory and activate it:Now you can put whatever files are generated by your development tools into your
.gitignore
file.You can have a
.gitignore
in every single directory of your project.However, the best practice is to have one single
.gitignore
file on the project root directory, and place all files that you want to ignore in it, like this:Once you create the
.gitignore
file, the ignore files that have changes or are new into the repository will not be shown to as waiting for commit.You can also have one global local git ignore file, that will manage all of your git repositories.
git config --global core.excludesfile ~/.gitignore_global
This alternative is particularly interesting for ignored files that are non-project related, such as IDE related files and so on.