iOS source code control git

Source: Internet
Author: User
Tags using git git commands

about git.

Git is an open source, distributed version Control tool

Of all the distributed version control tools in the world, Git is the fastest, simplest, and most popular

The origins of Git

The author is the father of Linux: Linus Benedict Torvalds

Git was developed only to assist with the development of the Linux kernel (managing source code)

The status quo of git

Abroad is already very popular, not popular in China (in the gradual popularization)

More and more open source projects have been moved to Git

The local operation of the Git.

The. Git command-line help

$ git Help

View Help for all Git commands

$ git help subcommand

# to exit the help message, press "Q"

# turn to the next page, press "Space"

# Look over the page and press "Ctrl+b"

# to search for relevant text, press "/" and enter "related text"

02. Create code Base & Configure personal Information

1> Creating a code Warehouse

$ git init

2> Configuring user names and Mailboxes

$ git config user.name manager

$ git config user.email [email protected]

* The above two commands will save the user information in the current code repository

3> If you want a one-time configuration complete, you can use the command

$ git config--global user.name Manager

$ git config--global user.email [email protected]

* The above two commands will save the user information in the. gitconfig file in the user directory

4> View all current configurations

$ git config-l

03. Actual Development

1> create code and start developing

$ Touch MAIN.C

$ open MAIN.C

2> Adding code to the code base

# View current Code library status

$ git status

# Add a file to the code base

$ git Add main.c

# Commit the changes to the code base

$ git commit-m "added main.c"

Tips:

* Be sure to use the-m parameter to specify modified memo information

* Otherwise it will enter the VIM editor, if not familiar with vim, it would be a terrible thing

# Add all new or modified files under the current folder to the code base at once

$ git Add.

3> Adding multiple Files

$ Touch Person.h person.m

$ git Add.

$ git commit-m "person class added"

$ open Person.h

$ git Add.

$ git commit-m "Add Person class attribute"

* Note that when you use git, each modification needs to be added and resubmitted, which is not the same as SVN

04. Aliases & Logs

$ git config alias.st status

$ git config alias.ci "commit-m"

Unless it's a special reason, it's best not to set an alias, or another machine won't work.

# View all repository logs

$ git log

# View repository logs for specified files

$ git log file name

# Configure a color log alias (This is a great tool for viewing versions)

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 '

05. Version number, let's shuttle between any version

# back to the current version, discard all uncommitted changes

$ git reset--hard HEAD

# Back to previous version

$ git reset--hard head^

# Back to the previous 3rd revision

$ git reset--hard head~3

# back to the version of the specified version number

$ git reset--hard e695b67

# View Branch Reference records

$ git Reflog

The actions that Git has developed in the team

01. Building a code warehouse (a code warehouse dedicated to team development)

# switch Directories

$ cd/users/desktop/Company/weibo

# Create a blank code base (specifically for team development)

$ git init--bare

02. Project Manager Preparation project (Prelude)

# switch Directories

$ cd/users/desktop/Manager

# "clone" code library to Local

$ git clone/users/desktop/company/weibo/

# Personal Information Configuration

$ git config user.name manager

$ git config user.email [email protected]

. gitignore

--------------------------------------------------------------------------------

. Gitignore can specify which files are not included in the repository's management

Reference URL: Https://github.com/github/gitignore

# command line to enter a directory with a. Git sibling

$ cd/users/desktop/git Walkthrough/manager/weibo

Paste the following command to the command line at once

--------------------------------------------------------------------------------

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

# Should judge for yourself, the pros and cons is mentioned at:

# Http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control

#

# pods/"> Gitignore

--------------------------------------------------------------------------------

# Add. Gitignore to the code base

$ git Add. Gitignore

03. Create a Project

1. Use Xcode to create a project to a previous manager's project directory

2. Submit the code using Xcode and push to the remote

04. New entrants

1. Clone the project locally

git Clone remote Warehouse address

2. Configure the user

#$ git config user.name SSD

#$ git config user.email [email protected]

3. Add the Person class

4. The commit code commit + push in Xcode

5. Update code Pull

04. Suggestions for using GIT in development

1. Create a User test folder

2. Checkout the company project git clone svn, and if it is git, delete the. git hidden folder and delete the. SVN hidden file if it's SVN. To disconnect from the corporate server

3. Git init creates a repository

4. Git Add. Add items to the local staging area

5. Git commit-m "initialize local repository"

So you can play happily in the company code!!!

iOS source code control git

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.