Getting Started with Git

Source: Internet
Author: User

1. Create repository git init

First Use git init to create an empty repository locally, execute the command

#mkdir-P/demo/helloworld-git

#cd/demo/helloworld-git

Create a working directory of open source projects, enter the working directory, execute commands #git init.

2. Submit the file to the 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

3. Create a local branch -git branch

GIT provides a branch, a source code may be done by multiple people, and the developer will create a branch for each modification so that the commit does not affect the code of the main branch after the modification. Show branches:# git branch, build branch:# git branch new-branch.

4. Switch local branch -git checkout

#git checkout new-branch--To switch the local branch to new-branch

5. Create an open source project on GitHub.

6. Upload the source code to GitHub git push

GitHub uploads code as neededSSHCheck, use command "# ash-keygen-t Rsa-c "RegisterGitHubwhen you enter theEmail "", in~/.sshgenerate a key file in the directoryId_rsaand a public key fileid_rsa.pub, if these two files already exist, you need to back up. #ssh-T [email protected]--detects the public key, the secret key, and the correct settings just now. Use the command "# Git push-u Origin master"uploads files from the local repository toGitHub.

7. Download Source code -git clone from GitHub

Execute the command "# git clone Engineering Catalog" To download the entire project you need. To get the latest content for a branch, you can use the command "# Git pull Origin master".

Getting Started with Git

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.