Common git commands

Source: Internet
Author: User

A simple summary of GIT commands is done to prevent you from getting back when you forget a command.

git config: Lists subcommands under the config command

git config global user.name "": Set global variable User.Name

git config global user.email ""; Set global variable User.email

git config-l or git config--ls: List variables already set under Config

git log: View the history of the current warehouse

Git status: View the status of the current working directory

Git status-s: A simplified git status command

Three states of Git:

git add hello.py: submits hello.py from working directory to staging area.

git clone/http:

git rm hello.py: delete hello.py files in working directory and staging area.

git rm--cached hello.py: Delete hello.py file in staging area. Note: Staging area is also called cache or index

git mv hello.py hello.txt: rename hello.py files in working directory and staging area. The equivalent of the following three operations:

git rm--cached hello.py, MV hello.py hello.txt, git add hello.txt

Git commit-m ': Submit staging Area to Repository (history).

Git commit-am ': Submit working directory to staging area and repository (history).

Git stash: Put the files in your current cluttered working directory into a drawer that can be removed later for unwinding. Note: At this point, the working directory,staging area is in line with Repository (history) and reverts to its original state.

Git stash list: The working directory that will be placed in the drawer is listed.

Git stash pop: Expand the working directory in the drawer and revert to the working directory status in the drawer.

git diff: See the difference between working directory and staging area.

git diff--staged: See the difference between staging area and repository (history).

The difference between git diff head:working directory and repository (history).

Git diff--stat Head: simplifying the command git diff head

git reset hello.py: Use repository files to overwrite staging area files to roll back staging area.

git checkout hello.py: Use staging area files to overwrite working directory files, to roll back working directory.

git checkout HEAD hello.py: Use repository files to overwrite working directory files, to roll back working directory.

Git commit-a-m ' Add file ' hello.py or git commit-am ' Add file ' hello. PY: Submitted directly from working directory to Repository (history). Note: hello.py must already be versioned by the file, that is, the file has been previously git add operation.

The following commands are for the history (repository) region:

The history (repository) region stores n commit objects, each commit object containing two parts, 1.tree: All files under this version, in the form of trees, 2.parent: pointers, pointing to the previous commit object.

Git cat-file-t head (which can also be the hashcode of a Commit object): Lists the commit object that the head points to.

Git cat-file-p head (which can also be the hashcode of a Commit object): Directly opens the Commit object that the head points to.

To be continued---

Common git commands

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.