Current location - Music Encyclopedia - Chinese History - Git basic operation command
Git basic operation command
Git basic operation commands include initial initialization, basic work operation, warehouse initialization, viewing the current state of the warehouse, file-related operations, viewing history, etc.

First, initialize for the first time

Git initialization.

Git add.

git commit-“m first commit”。

Git remotely adds origingit @ github.com: account name/warehouse name.git.

Git pulls the origin master.

Git pushes the origin master#-f strong.

Git clone git@github.com:git account name/warehouse name.git.

Second, the basic operation of the work

Git checkout master cuts into the main branch.

Git fetch origin gets the latest changes.

Git checkout-b dev origin/master creates a dev branch based on the main branch.

Git add. Add to the cache.

Gitcommit-m' XXX' is submitted to the local warehouse.

Git fetch origin gets the latest changes.

Third, initialize the warehouse.

Git initialization.

Fourth, check the current status of the warehouse.

Git status.

Verb (abbreviation for verb) file-related operations

1. Add files to the repository.

Git add file name adds files in the workspace to the temporary area.

Git add. Add all files in the current workspace to the temporary storage area.

Git add-u adds all the modified or deleted file information in the tracked file to the temporary storage area, and does not process untracked files.

Git add-A adds all the modified or deleted file information in the tracked file to the temporary storage area, including untracked files.

Git add-i enters the interactive interface mode and adds files to the cache as needed.

2. Submit the temporary storage file to the local warehouse.

Git commit-m "Submit Description" submits the contents of the temporary storage area to the local warehouse.

Git commit-a-m "Submit Description" skips the operation of the cache area and directly submits the contents of the workspace to the local warehouse.

3. Compare the similarities and differences of documents

The difference between git diff workspace and temporary storage area.

Git diff branch name The difference between the workspace and the branch, the remote branch is written as follows: remote/origin/branch name.

The difference between the git diff HEAD workspace and what the HEAD pointer points to.

Git diff submits the difference between the current version and the version history of the file in the id file path workspace.

Gitdiff–the difference between the stage workspace file and the last submission (–––– cached before 1.6).

Git diff version tab to see all the changes since a version.

Git diff Branch A Branch B compares the differences between Branch A and Branch B (also supports comparing two tags).

Git diff branch A… branch b compares the changes after the separation of two branches.

In addition: If you only want to count which files have been modified and how many lines have been modified, you can add the -- stat parameter.

Sixth, check the history

Git log views all submission records (SHA-A checksum, author's name, email address, submission time, submission instructions).

Git log-p- the number of times to view the latest submitted record.

Gitlog–stat briefly displays each submitted content change.

Gitlog–name-only displays only the list of files that have been modified.

Displays a list of files added, modified and deleted.

Gitlog–one line allows the submitted records to be output in compressed rows.

Gitlog–graph–all–online graphically displays the merger history of branches.

Gitlog–author = the author inquires about the author's contribution record (add a -- all-match parameter when using grep at the same time).

Gitlog–grep = filterinformation lists submission records with filtered information in the submission information.

The query content of git log-S is similar to that of -- grep, and there is no space between s and the query content.

View the modification record of the file.