Git Common Command Collation

Source: Internet
Author: User


------Create a library-------------------

1. Create a local repository
Git init

2. Add Files
git add fileName

3. Submit to Library
git commit-m "message"

------version control, modify-------------------

1. Workspace modification Fallback
Git checkout--fileName

2. Modified fallback for add to staging area
git reset HEAD fileName and then use checkout

3. Commit to Repository modification fallback
git log to look at the log, then git reset--hard head^ (or the specific ID of the version)

4. deleting files
git rm fileName

------Remote Repository-------------------

1. Create a remote repository and associate it locally
git remotes Add origin remote code base address/learngit.git

2. Push local files to remote
Git push-u Origin Master (-U represents the first time)

3. Cloning code on the remote
git clone [email protected]:michaelliao/gitskills.git

------Branch-------------------

1. Create, switch branches
Git branch Dev
git checkout Dev

2. Create + Toggle Branch
Git checkout-b <name>

3. View Branches
Git branch

4. Merging a branch to the current branch
git merge <name>

5. Delete a branch
Git branch-d <name>

------Other-------------------

1. View status
git status

2. View Changes
Git diff

3. View the change history
git log [--pretty=oneline]

4. View each command
Git reflog

5. View Files
Cat FileName

Git Common Command Collation

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.