很多Git命令都是在命令行下运行的,命令行下管理Git有很多优点不用多说。但最大的缺点是要求用户记住这些命令。因此Git图形界面还是很受一些用户欢迎的,其中Xcode作为集成开发环境工具,也提供了一定Git图形界面功能。但是要想在Xcode中使用Git管理工程代码还想需要进行一些配置,然后才能使用。
如果我们是使用Xcode 4创建的一个iOS工程,在终端的命令行中提交代码时候,可能会出现下面的部分信息:
[cpp]
create mode 100644 HelloWorld/HelloWorld.xcodeproj/project.xcworkspace/contents.xcworkspacedata
create mode 100644 HelloWorld/HelloWorld.xcodeproj/project.xcworkspace/xcuserdata/tonyguan.xcuserdatad/UserInte易做图ceState.xcuserstate
create mode 100644 HelloWorld/HelloWorld.xcodeproj/xcuserdata/tonyguan.xcuserdatad/xcschemes/HelloWorld.xcscheme
create mode 100644 HelloWorld/HelloWorld.xcodeproj/xcuserdata/tonyguan.xcuserdatad/xcschemes/xcschememanagement.plist
rewrite HelloWorld.xcodeproj/project.xcworkspace/xcuserdata/tonyguan.xcuserdatad/UserInte易做图ceState.xcuserstate (83%)
create mode 100644 HelloWorld/HelloWorld.xcodeproj/project.xcworkspace/contents.xcworkspacedata
create mode 100644 HelloWorld/HelloWorld.xcodeproj/project.xcworkspace/xcuserdata/tonyguan.xcuserdatad/UserInte易做图ceState.xcuserstate
create mode 100644 HelloWorld/HelloWorld.xcodeproj/xcuserdata/tonyguan.xcuserdatad/xcschemes/HelloWorld.xcscheme
create mode 100644 HelloWorld/HelloWorld.xcodeproj/xcuserdata/tonyguan.xcuserdatad/xcschemes/xcschememanagement.plist
rewrite HelloWorld.xcodeproj/project.xcworkspace/xcuserdata/tonyguan.xcuserdatad/UserInte易做图ceState.xcuserstate (83%)
事实上是能够列入到代码版本控制的文件是有规定的,不能是编写的二进制文件、临时文件和用户特有的文件等。下面是Xcode 4创建的HelloWorld工程的目录结果:
HelloWorld
[cpp]
├── HelloWorld
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── HelloWorld-Info.plist
│ ├── HelloWorld-Prefix.pch
│ ├── ViewController.h
│ ├── ViewController.m
│ ├── en.lproj
│ │ ├── InfoPlist.strings
│ │ └── ViewController.xib
│ └── main.m
└── HelloWorld.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcuserdata
│ └── tonyguan.xcuserdatad
│ └── UserInte易做图ceState.xcuserstate
└── xcuserdata
└── tonyguan.xcuserdatad
├── xcdebugger
│ └── Breakpoints.xcbkptlist
└── xcschemes
├── HelloWorld.xcscheme
└── xcschememanagement.plist
├── HelloWorld
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── HelloWorld-Info.plist
│ ├── HelloWorld-Prefix.pch
│ ├── ViewController.h
│ ├── ViewController.m
│ ├── en.lproj
│ │ ├── InfoPlist.strings
│ │ └── ViewController.xib
│ └── main.m
└── HelloWorld.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcuserdata
│ └── tonyguan.xcuserdatad
│ └── UserInte易做图ceState.xcuserstate
└── xcuserdata
└── tonyguan.xcuserdatad
├── xcdebugger
│ └── Breakpoints.xcbkptlist
└── xcschemes
├── HelloWorld.xcscheme
└── xcschememanagement.plist
其中HelloWorld.xcodeproj属于包文件,它内部的很多东西是不能提交的,包括:project.xcworkspace和xcuserdata,它们是与用户有关的。Git中有一个.gitignore配置文件,在这个文件中可以设置被忽略的文件。下面的内容是一个.gitignore配置文件:
[cpp]
# Exclude the build directory
build/*
# Exclude temp nibs and swap files
*~.nib
*.swp
# Exclude OS X folder attributes
.DS_Store
# Exclude user-specific XCode 3 and 4 files
*.mode1
*.mode1v3
*.mode2v3
*.perspective
*.perspectivev3
*.pbxuser
*.xcworkspace
xcuserdata
# Exclude the build directory
build/*
# Exclude temp nibs and swap files
*~.nib
*.swp
# Exclude OS X folder attributes
.DS_Store
# Exclude user-specific XCode 3 and 4 files
*.mode1
*.mode1v3
*.mode2v3
*.perspective
*.perspectivev3
*.pbxuser
*.xcworkspace
xcuserdata
文件中#号是注释,可以使用正则表达式,文件考虑到了X code 3和4差别。这个文件创建之后,应该放在什么地方?如果只考虑对一个特定工程忽略,.gitignore文件应该放在代码库目录下面,目录结构如下所示:
<代码库目录>
[cpp]
└── HelloWorld
├── HelloWorld
补充:移动开发 , IOS ,