美文网首页iOS开发iOS 知识点iOS学习
iOS项目使用git管理代码.gitignore设置问题

iOS项目使用git管理代码.gitignore设置问题

作者: X勒个F | 来源:发表于2018-01-24 13:57 被阅读525次

使用Xcode管理代码时,会产生一些文件影响代码同步,比如UserInterfaceState.xcuserstate,需要设置忽略这些文件,在.gitignore文件中可以设置相应的忽略文件。

首先最好有一个空项目(因为已经上传的项目中的文件再设置.gitignore对已上传的文件无效),github、gitlab、码云都可以。将项目克隆到本地。 WX20180124-113612@2x.png

点击项目,按shift + command + .可以查看隐藏文件,再次可以隐藏。可以看到上图的.git文件。

cd到该项目,创建.gitignore文件。如下图: WX20180124-114924@2x.png

打开.gitignore文件将下面代码粘贴进去。

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

## Build generated
build/
DerivedData/

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

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

## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM


# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output

# Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/

https://github.com/github/gitignore 源代码在这儿,只添加了忽略
*.xcuserstate
*.DS_Store
文件。
修改完保存,将修改后的项目上传就可以了。以后再提交代码就会忽略.xcuserstate和.DS_Store文件了。

如果项目不是空项目,建议先把完整项目备份好,删掉除.git文件夹以外的所有文件,然后上传。最后,再按上面的步骤走一遍,再把备份项目除去.git文件夹和.gitignore文件拷贝进去,再将代码上传就行了。

相关文章

  • iOS项目使用git管理代码.gitignore设置问题

    使用Xcode管理代码时,会产生一些文件影响代码同步,比如UserInterfaceState.xcusersta...

  • Git配置Java开发环境的.gitignore文件

    一、为什么要配置.gitignore? 在使用git管理java项目时,如果没有配置.gitignore,会把除源...

  • git相关命令

    1. git首次提交 设置全局参数 上传代码 2. git新增gitignore文件 在项目路径下添加.gitig...

  • [转载]用对 gitignore

    使用 git 做代码管理工具时,设置 gitignore 是必不可少的流程,一些系统或者 IDE 会在目录下生成与...

  • git

    使用Git管理项目 一、 在Github上建立仓库 二、在项目根目录创建.gitignore文件 三、初始化git...

  • Git 之.gitignore

    .gitignore,顾名思义——git ignore,是使用git管理项目时,存放忽略文件规则的文档。 对应规则...

  • 第四个模块 Git让.gitignore生效

    Git 代码管理中 .gitignore 文件无效的解决方法 Git 代码管理中,我们在没有添加 .gitigno...

  • Git项目管理命令以及常见错误

    在工作中,使用Git进行项目管理越来越常见,Git项目管理命令也成为iOS攻城狮的基本功.不多说直接上代码: 远程...

  • gitignore 无效

    Git 代码管理中,我们在没有添加 .gitignore 文件的前提下提交了代码之后再提交 .gitignore ...

  • Git使用之.gitignore

    这篇文章主要讲.gitignore在Xcode中的使用 关于.gitignore 在Xocde中使用git管理版本...

网友评论

    本文标题:iOS项目使用git管理代码.gitignore设置问题

    本文链接:https://www.haomeiwen.com/subject/zqzyaxtx.html