.gitignore file, where should I put it in my xcode project?

后端 未结 6 2189
无人共我
无人共我 2021-01-29 22:04

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 .

6条回答
  •  青春惊慌失措
    2021-01-29 22:14

    where should i put the .gitignore file?, is it inside the .git folder?

    There 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):

    git config alias.exclude "!sh -c 'echo \"$1\" >> .git/info/exclude' -"
    git exclude UserInterfaceState.xcuserstate
    

    If you need to exclude this file for all similar project, as Elnur Abdurrakhimov mentioned in his answer, exclude it globally.

    echo UserInterfaceState.xcuserstate >> ~/.gitignore
    

    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:

    *.xcuserstate 
    

    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 GitHub Objective-C.gitignore file.

提交回复
热议问题