Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the commonly used Git commands

Shulou Source: shulou.com Published: 2022-06-02 21:20:00 10月22日 Update

This article mainly introduces "what are the commonly used Git commands". In daily operation, I believe many people have doubts about which commonly used Git commands. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "what commonly used Git commands are there?" Next, please follow the editor to study!

1. Multiple git commands separated by ";" (semicolon)

Separated by semicolons, you can use multiple Git commands:

$git-version; git branch / / separated by semi-colon

2. Git alias command

Command aliases can improve reusability.

Alias gitremote-v (the command used to check the remote source) as show-origin:

$git config-- global alias.show-origin remote-v $git show-origin

Alias git log-- graph--pretty=oneline (the command to print and submit logs) to show-graph:

3. Hidden folder named '.git'

The hidden .git folder contains a history of submissions, branches, and files. Therefore, you need to copy the .git folder and copy the entire application and git history (submission history, etc.). To copy hidden folders, run the-r option:

$cp-r

To view hidden folders, you need to run ls-an instead of ls:

$ls-a

4. Multiple ways to specify folders and files in '.gitignore'

The .gitignore configuration file contains files and folders that you do not want to manage on the git system. There are many ways to specify folders and files in .gitignore. First, # in .gitignore is used for comments (similar to # comments in Python).

(1) simple file name

# exclude dbinfo.php file in git system dbinfo.php

(2) pattern matching-"globbing" uses an asterisk (*)

Globbing is the wildcard technology used by most Unix shell:

# exclude obj files * .obj

(3) specify files or folders that you do not want to exclude

You can specify files or folders that you do not want to exclude. This is useful when working with a team and want to restate that the file or folder should not be excluded from the git system:

# do not exclude the following configuration file! config.php

(4) relative path of file

# exclude the file in the current directory / readme.txt# exclude all files in / pub/ directory / pub/# exclude all txt files whose parent is docdoc/**/*.txt

5. Blank information option

Sometimes if you want to submit without information, but the information is a necessary condition for submission, you can use the-- allow-empty-message option:

$git commit-allow-empty-mesage-m ""-no commit message

6. Branching hierarchical structure

When there is a slash (/) in the branch, the branch is stored as a directory hierarchy:

Branch name-- > v1.5/feature-1-- > v1.5 v1.6/feature-2 v1.6/feature-2-- > v1.6/feature-3-- > v1.6/fix-1

7. Show Log

There are several ways to display git logs:

(1) pretty=online option

$git log-pretty=onelineOR$ git log-oneline

(2) Chart options

$git log-online-graph

(3) numeric option

$git log-- online-- graph-5 / / SHOW only 5 most recent commits so far, the study of "what are the commonly used Git commands" is over. I hope I can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Files folders commands frequently used branches methods learning information history logs middle fingers semicolons aliases multiple multiple hierarchical more comments systems structures Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info MySQL MariaDB Xiaomi NVidia