IOS development-configure and use git in xcode

Source: Internet
Author: User
Tags using git git commands

Many git commands are run in the command line, and managing git in the command line has many advantages. However, the biggest drawback is that you need to remember these commands. Therefore, the git gui is very popular among some users. xcode, as an integrated development environment tool, also provides a git GUI function. However, to use git in xcode to manage the project code, you still need to configure it before using it.

If we create an iOS project using xcode 4, the following information may appear when submitting code in the command line of the terminal:

Create mode 100644 helloworld/helloworld. xcodeproj/Project. xcworkspace/contents. xcworkspacedata

Create mode 100644 helloworld/helloworld. xcodeproj/Project. xcworkspace/xcuserdata/tonyguan. xcuserdatad/userinterfacestate. 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/userinterfacestate. xcuserstate (83%)

In fact, it is stipulated that files that can be included in code version control cannot be compiled binary files, temporary files and user-specific files. The following is the directory result of the helloworld project created by xcode 4:

Helloworld

── 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

│ ── Userinterfacestate. xcuserstate

── Xcuserdata

── Tonyguan. xcuserdatad

── Xcdebugger

│ ── Breakpoints. xcbkptlist

└ ── Xcschemes

├ ── Helloworld. xcscheme

── Xcschememanagement. plist

Among them, helloworld. xcodeproj is a package file, and many items in it cannot be submitted, including project. xcworkspace and xcuserdata, which are user-related. Git has a. gitignore configuration file, in which you can set the file to be ignored. The following is a. gitignore configuration file:

# 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

# Is a comment in the file. You can use a regular expression. The differences between X code 3 and 4 are considered in the file. After this file is created, where should it be stored? If you only want to ignore a specific project, the. gitignore file should be placed under the code library directory. The directory structure is as follows:

<Code library directory>

── Helloworld

── Helloworld

│ ── Appdelegate. h

│ ── Appdelegate. m

│ ── Default-568h@2x.png.

│ ── Ult.png

│ ── Default@2x.png.

│ ── Viewcontroller. h

│ ── Viewcontroller. m

│ ── HelloWorld-Info.plist.

│ ── HelloWorld-Prefix.pch.

│ ├ ── En. lproj

│ ├ ── Infoplist. Strings

│ ── Mainstoryboard. storyboard

│ ── Main. m

── Helloworld. xcodeproj

──. Gitignore

If it applies to all xcode projects, you need to use the GIT config command to configure git and execute the GIT config command in the terminal:

$ Git config-global core. excludesfile ~ /. Gitignore

This command writes the configuration information~ /. GitconfigFile,-GlobalThe parameter indicates the global configuration information,~ /. GitignoreThe description file is stored in the current user directory.

To enable all the code libraries on the local machine to use git users by default, you also need to execute the following command for Configuration:

$ Git config-global user. Name git

$ Git config-global user. Email eorient@sina.com

There are still many problems when using git in xcode. laoguan summarized the four common problems and shared them with you tomorrow. You have to work on them.

Question 1: How do I create a code library in xcode and add and submit code to the code library?

Question 2: How can I submit the push to the remote server code library in xcode?

Question 3: How can I clone a remote server code library to a local machine in xcode?

Question 4: How can I use xcode to obtain remote code library data and solve conflicts?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.