Use ios xocde git

Source: Internet
Author: User

Use ios xocde git

02. GIT Command Line Help
========================================================== ==========================================================
$ Svn help
View the help of all svn commands
$ Svn help sub-command


# To exit the help information, press "q"
# Go to the next page and press "space"
# Read the previous page and press "CTRL + B"
# To search for related text, press "/" and enter "related text"


03. Create a code library and configure personal information
========================================================== ==========================================================
1> Create a code repository
$ Git init

2> Configure the user name and email address
$ Git config user. name aa
$ Git config user. email aa@gmail.com

* The preceding two commands Save User information in the current code repository.

# Git can identify the operator's personnel information only after the user and email are configured. You can set some actions through the hooks program.
# For example, an email is automatically sent to the relevant personnel after the unit test finds a problem.

3> to complete one-time configuration, run the following command:
$ Git config -- global user. name aa
$ Git config -- global user. email aa@gmail.com

* The preceding two commands Save User information in the. gitconfig file in the user directory.

4> View all current configurations
$ Git config-l

04. Actual development
========================================================== ==========================================================
1> Create Code and start development
$ Touch main. c
$ Open main. c

2> Add the code to the code library
# View the status of the current code library
$ Git status
# Add files to the code library
$ Git add main. c
# Submit the modifications to the code library
$ Git commit-m "added main. c"

Tip:
* You must use the-m parameter to specify the modified remarks.
* Otherwise, you will enter the vim editor. If you are not familiar with vim, it will be very bad.

# Add all new or modified files in the current folder to the code library at one time
$ Git add.

3> add multiple files
$ Touch Person. h Person. m
$ Git add.
$ Git commit-m "added the Person class"
$ Open Person. h
$ Git add.
$ Git commit-m "adding Person class attributes"

* When Using git, you must add and submit each modification. This is different from svn.

Important Concepts and working principles of git
--------------------------------------------------------------------------------
Work Zone
Staged)
Branch (HEAD)

05. Alias & log
========================================================== ==========================================================
$ Git config alias. st status
$ Git config alias. ci "commit-m"

Personal suggestion: unless for special reasons, it is best not to set an alias, otherwise it will not be used for another machine

# View all version database logs
$ Git log
# View the version database logs of a specified file
$ Git log File Name


# Configure log aliases with colors
$ Git config -- global alias. lg "log -- color -- graph -- pretty = format: '% Cred % h % Creset-% C (yellow) % d % Creset % s % Cgreen (% cr) % C (bold blue) <% an> % Creset '-- abbrev-commit"

Tip: In git, the version number is a hash value generated by SHA1.

06. version number, let's move between any version
========================================================== ==========================================================
# Return to the current version and discard all unsubmitted changes
$ Git reset -- hard HEAD
# Return to the previous version
$ Git reset -- hard HEAD ^
# Return to the previous 3rd revisions
$ Git reset -- hard HEAD ~ (3)
# Return to the version of the specified version
$ Git reset e695b67

# Viewing branch reference records
$ Git reflog

07. Modify and manage a single file
========================================================== ==========================================================
# Viewing file changes
$ Git diff
# Revoking modifications to files
$ Git checkout Person. h

# Deleting files from the code library (temporary storage area)

Zookeeper -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

01. Create a code repository (a code repository dedicated for Team Development)
========================================================== ==========================================================
# Switch Directories
$ Cd/Users/aa/Desktop/git walkthrough/Company/weibo
# Create a blank code library (dedicated for Team Development)
$ Git init -- bare

02. The project manager Prepares the project (Prelude)
========================================================== ==========================================================
# Switch Directories
$ Cd/Users/aa/Desktop/git Drill/Manager
# "Clone" code library to local
$ Git clone/Users/aa/Desktop/git Drill/Company/weibo/

# Personal Information configuration (because you want to demonstrate multi-person collaboration on a machine, daily development can be ignored)
$ Git config user. name manager
$ Git config user. email manager@163.com

. Gitignore
--------------------------------------------------------------------------------
. Gitignore can specify which files are not included in the version library management.

Reference: https://github.com/github/gitignore

# Enter the directory at the same level as. git in the command line
$ Cd/Users/aa/Desktop/git Drill/manager/weibo

Paste the following command into the command line at one time
--------------------------------------------------------------------------------
Echo-e "# Xcode
#
Build/
*. Pbxuser
*. Mode1v3
*. Mode2v3
*. Perspectivev3
Xcuserdata
*. Xccheckout
*. Moved-aside
DerivedData
*. Hmap
*. Ipa
*. Xcuserstate
# CocoaPods
#
# We recommend against adding the Pods directory to your. gitignore. However
# You shoshould judge for yourself, the pros and cons are mentioned:
# Http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
#
# Pods/">. gitignore
--------------------------------------------------------------------------------
# Add. gitignore to the code library
$ Git add. gitignore

03. Create a project
========================================================== ==========================================================
Submit "push" to remote code repository at the same time

04. New users join
========================================================== ==========================================================

05. Distributed code library-for reference only
========================================================== ==========================================================
Because git is distributed, the entire code library is retained on any computer, so you can place the code library developed by the team anywhere.

Synchronization drills between multiple remote code libraries "Tip: this drill is only for your understanding. The specific use requires a certain team size before you can understand it"

06. branch management-Tag
========================================================== ==========================================================
# View the current tag
$ Git tag
# Add a tag to the project in the local code library
$ Git tag-a v1.0-m 'version 1.0'
# Push tags to remote code library
$ Git push origin v1.0

# Using tags, you can quickly switch a project to an intermediate state, such as a stable version of the product development line.
# Check out the v1.0 tag
$ Git checkout v1.0
# Create a v1.0bugfix branch from the check-out status
$ Git checkout-B bugfix1.0


# Viewing remote branches
$ Git branch-r
# Deleting a remote Branch
$ Git branch-r-d origin/bugfix1.0


Zookeeper -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

01. Distributed code library-for reference only
========================================================== ==========================================================
Because git is distributed, the entire code library is retained on any computer, so you can place the code library developed by the team anywhere.

Synchronization drills between multiple remote code libraries "Tip: this drill is only for your understanding. The specific use requires a certain team size before you can understand it"

02. branch management-Tag
========================================================== ==========================================================
# View the current tag
$ Git tag
# Add a tag to the project in the local code library
$ Git tag-a v1.0-m 'version 1.0'
# Push tags to remote code library
$ Git push origin v1.0

# Using tags, you can quickly switch a project to an intermediate state, such as a stable version of the product development line.
# Check out the v1.0 tag
$ Git checkout v1.0
# Create a v1.0bugfix branch from the check-out status
$ Git checkout-B bugfix1.0

# Viewing remote branches
$ Git branch-r
# Deleting a remote Branch
$ Git branch-r-d origin/bugfix1.0

Zookeeper -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Procedure for connecting the Xcode project to GITHUB
Cd ~ /. Ssh
# Generate an rsa key. The key secret key is 123456.
Ssh-keygen-t rsa-C "xxx@gmail.com"
# Copy the key file to the clipboard
Pbcopy <~ /. Ssh/myname_rsakey.pub


# Go To github and set the ssh key
#1. Edit Profile
#2. SSH Keys
#3. Add SSH Key
#4. paste the copied Key and submit it.


# Add an rsa key
Ssh-add myname_rsakey
# Test github connection
Ssh-T git@github.com


# Associated projects
Cd project folder/
# Initialize git for the current folder
Git init
# Add a remote server
Git remote add origin git@github.com: liufan321/HelloWorldDemo. git
# Pulling projects from the server
Git pull-u origin master
# Push project content to the server
Git push-u origin master

Zookeeper -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1. git init -- bare shared. git
Create an empty version Library

2. git clone ~ /Desktop/gitdemo/repository/shared. git/
Clone the code from the version Library to the working directory

3. git add.
Add all modified files to the temporary storage area

4. git commit-m "modified information"
Submit the file to the local code repository

5. git push origin master
Push the modifications in the local code repository to the master branch of the remote code repository.

6. git pull
Pull the latest content from the remote code repository to the local code library

7. git status
View the File status of the local code repository

* ** To use. git in Xcode for team development, you must set the. gitignore file.
Note: The. gitignore file is used to specify which files or folders are ignored when the file is submitted.

The procedure is as follows:
1>
# Delete the UserInterfaceState. xcuserstate file from the cache area
Git rm -- cached MyDemo/MyDemo. xcodeproj/project. xcworkspace/xcuserdata/aplle. xcuserdatad/UserInterfaceState. xcuserstate

Or
# Force Delete the UserInterfaceState. xcuserstate File
Git rm-f MyDemo/MyDemo. xcodeproj/project. xcworkspace/xcuserdata/aplle. xcuserdatad/UserInterfaceState. xcuserstate

2> vim. gitignore
And Paste
Project. xcworkspace
: Wq save and exit

After the above. gitignore file is created, all files in the project. xcworkspace directory will be ignored, including interface records, breakpoint records, and other information.

 


Zookeeper -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

GIT branch drill notes

1. Create an empty code library named shared. git
========================================================== ==========================================================
Git init -- bare shared. git

2. Prepare code
========================================================== ==========================================================

1> clone the code library
Git clone ~ /Desktop/gitdemo/repository/shared. git/

2> Configure the user information of the current code library (skip this step if you have configured global user attributes)
# Enter the shared working directory
Cd shared
# Configure the user name
Git config user. name manager
# Configure user email
Git config user. email manger@163.com

3> open Xcode to create a project and save it to the shared directory.

4> ignore unnecessary user data files
# View the current status to select a User File
Git stauts

# The specific directory name is determined based on the project location. Note that the file name at the end is UserInterfaceState. xcuserstate.
Git rm-f IWeibo o/IWeibo O. xcodeproj/project. xcworkspace/xcuserdata/liufan. xcuserdatad/UserInterfaceState. xcuserstate

# Generate a. gitignore File
Echo "project. xcworkspace">. gitignore

# Add the. gitignore file to the temporary storage Zone
Git add.

# Submit all modifications to the local code library
Git commit-m "new project"

5> Use Xcode to open the project, adjust the code, and submit the adjusted code to the local code library.
Note: If you select "Push To Remote", the following three operations will be performed when you click the Commit button:
(1) Add the modified file to the temporary storage area
(2) Submit the files in the temporary storage area to the local code library.
(3) Submit the content of the local code library to the remote code library

6> Create a developer branch in Xcode for development.
Note: after creating a new branch, you must use the push function to push the changed branch to the remote code library. Otherwise, the branch can only be visible locally.

3. V1.0 Development
========================================================== ==========================================================
1> User01 develop and submit code on the developer Branch
2> after V1.0 is developed, the manager combines the code from the developer branch to the master branch.
3> the manager switches back to the master branch and adds the label to the command line.

# Add the v1.0 tag at the current time point
Git tag-a v1.0-m "Version 1.0"

# Push the v1.0 tag to the remote code library
Git push origin v1.0

# Viewing local labels
Git tag

# View local branches
Git branch

# View all branches
Git branch-

4> the manager releases the current v1.0 version.

4. Bug of modifying V1.0 in V2.0 Development
========================================================== ==========================================================
1> the manager creates the v1.0bugfix branch in the master branch and notifies User01 to modify it.

2> after receiving the Working command for Bug fixing in developing User01, stop working and submit the current code to the server

3> directly switch to the v1.0bugfix branch and revise the V1.0 bug. After the modification is complete, submit the code.

4> after the manager approves the code, the modified Code is integrated into the master line.

5> Add v1.1 labels to the Manager

# Add the v1.0 tag at the current time point
Git tag a v1.1-m "Version 1.0"

# Push the v1.0 tag to the remote code library
Git push origin v1.1

# Deleting a remote Branch
Git push origin -- delete V1.0bug _ fix

6> User01 integrate the modified Code into the developer's main line and start subsequent work

5. Functions of tags
========================================================== ==========================================================
In GIT, you can tag a branch at any desired time point, and switch the code back to the status at any other time point.

# Check out the v1.0 tag
Git checkout v1.0

# Create a branch for the code of the tag moment
Git checkout-B v1.0branch

# Deleting a remote tag
Git push origin -- delete tag

# Deleting a local tag
Git tag-d









 

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.