GIT basic operations and upload code to GitHub

Source: Internet
Author: User

1. Basic configuration:

Configure user name: Git config--global user.name "";

Configure mailbox: Git config--global user.email "";

View configuration: Git config--list

2. Basic Operation:

Create warehouse: Go to a directory and execute git init

Use the current polygon directory as a git repository: git add filename

Modify the file to add a line "AAAA"

Git commit-m '//is only submitted to staging area and not submitted to the repository

Git commit-am '//Add to cache and submit to Repository

3. Branch Management:

Git branch//view Branch

GIT branch br//Add BR Branch

Git checkout branch name//Switch Branch

Execute under the Master branch: git merge br//merge BR branches in Master Branch

4. View the log:

git log//normal view

git log--oneline//merge on one line to view

git log--oneline--graph//view in tree form

5. Back to version

Check log first, pointer git log--oneline

git reset--hard head pointer

6. Upload files to GitHub.

1. Register your GitHub account

2. Generate key pair ssh-keygen-t rsa-c [email protected]

3. Give the public key to GitHub

4. Create a warehouse on GitHub, the same as the warehouse name and the local warehouse. The URL of a remote repository is returned after creation is complete

5. Create a remote repository git remote add [shortname] [url]//shortname is the remote connection name, here named Orign

6. View the remote repository git remote-v

7. Upload code to remote repository: git push--set-upstream orign master//orign is the remote connection name for operation 5, master is branch

8. Refresh GitHub to view uploaded items

7. Download the code to the local repository

git fetch

git merge

GIT basic operations and upload code to GitHub

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.