Android system porting and Driver development--Chapter III Introduction to GIT and its application in learning

Source: Internet
Author: User
Tags using git

Chapter III Getting Started with Git

The purpose of using GIT is to reduce the compression size of various versions of Linux and provide source code to compile on Linux.

In this chapter, the key step is actually the operation, although Git is not very much associated with the android we are learning, but it is also essential in the development environment. Learn this chapter by learning how to install, view, and extract Git . The details are described below.

First, install Git

Perhaps most Linux already has git installed, if not available with the following command.

Ubuntu10.04 version below the-core with the original distinction,

Required: Apt-get install Git-core (differentiate)

Selected: Apt-get install Git-doc gits-svn git-email Git-gui gitk

If it's Rhel,fedora and CentOS, No.

Required: Yum install Git-core (differentiate)

Selected: Yum install git-doc gits-svn git-email Git-gui gitk

Must be under root authority

Second, view git documentation

Use the man command to view the help documentation for the specified command: Man git-checkout

Git's text format and HTML-formatted documents are installed after Git-doc is installed, all documents in the/usr/share/doc/git-doc directory

View the specified document as text: Git help <sub-command>

Document for viewing HTML formatting commands: Git help-w <sub-command>

III. submission and acquisition of source code

This section is primarily about using Git to get the code you want from the source-managed server and understanding the meaning of the git download Source command code.

1. Create repository git init

Build working directory and enter, execute git init, after the end of the following information will appear, but with LS do not display, to use the following command to display the hidden directory, is the local repository. You can now view its directories and subdirectories.

Mkdir-p/demoelloworld-git HelloWorld can be defined casually

Cd/demo/helloworld-git

Git init

Initialized Empty Git repository in/demo/helloworld-git/.git/

Ls–al

Git repository is divided into: local repository and remote repository, the local repository is not networked, that is, you are the owner, do not need any permissions. If someone wants to modify the source code in the server, you need to create an identical one with Git clone.

2. Commit a file to a local repository: git commit

Enter the directory, create files, add files to the local repository index

Cd/demo/helloworld-git

echo "HelloWorld" >helloworld.txt

git add helloworld.txt

Git commit-m ' helloworld-master '

Display log information: git log

Once the files in the working directory are submitted to the local database, it is no longer feared that the source code will be deleted or mistakenly changed.

3. Create a local branch git branch

This is based on different developers starting from all angles.

Create a new branch: Git branch New-branch (the * in front of the branch stands under which working directory branch)

Delete all previous modifications: Git branch-d new-branch

4. Local branch Git checkout

Local branches are designed to isolate changes in different parts of the main branch, and the git checkout command can be used to switch between different local branches. Use the following command to modify the contents of the Helloworld.txt file and resubmit it to the database.
Use the following command to switch the local branch to New-branch
git checkout New-branch
echo ' Hello World ' >helloworld.txt
git add helloworld.txt
Git commit-m helloworld-new-branch
Switching two branches back and forth will find that the contents of the HelloWorld change with the branch.

5. Create an open source project on GitHub

Now http://github.com/signup/free page Register a free user->create an account to create a user--login into the home page->create This is the interface will tell the user how to upload the source code

6. Upload source code to github git push

Since the transfer on GitHub needs to verify SSH, use the following command to generate a vault file and a public key file in the ~/.ssh directory if there will be a backup.

Ssh-heygen-t rsa-c "HelloWorld registered Mailbox"

Generated in plain text format, all copy to Clipboard, go to the left of the Account Settings page, select SSH public keys-> Click the Add link in the middle of the page, put the content you just copied to the key input box, detection key, The public key and the settings you just made are correct and will be completed successfully.

ssh-t [email protected]

If permission denied fails, enter the following command:

Ssh-add

git config--globaluser.name "Your name"

git config--globaluser.email [email protected]

git remote add origin [email protected]:androidguy/helloworld.git

git push-u orgin Master

Git branch-a

7. Download source code git clone from GitHub

Git clone[email protected]:androidguy/hellowrld.git

After the download is successful, it will be more HelloWorld directory

If you only want to get the latest content from a branch, use the following command

Git pullorigin Master

Android system porting and Driver development--Chapter III Introduction to GIT and its application in learning

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.