Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the commonly used Git commands

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report