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

Common commands of git (1)

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

Git configuration:

Git config-global user.name "Tina Gao"

Git config-global user.email "123@qq.com"

After executing the above command, a .gitconfig file is created in the home directory, which can be viewed as: cat ~ / .gitconfig

A warehouse in Clone: git clone http:....

Initialize a new warehouse:

Mkdir project

Cd project

Git init

Create a file:

Touch file1 file2 file3

Echo "test" > > file1

Echo "test" > > file2

Echo "test" > > file3

View the status of the current git repository:

Git status

Add the files of untracked to the cache with the git add command:

Git add file1 file2 file3

Check which files have been modified in the cache (diff compare contents):

Git diff-cached

Submit to local warehouse: git commit-m "add 3 files"

Synchronize the local warehouse to the remote server:

Git push origin master

A git repository can maintain many branches and create branches:

Git branch A

View the current branch: git branch

Switch to branch: git checkout master

After making changes on branch A, merge it into master:

Git checkout master

Git merge-m'merge A branch' A

When two branches change the same file, there will be conflicts that will lead to failure.

Undo the merger: git reset-- hard head ^

View the log: git log

Log statistics (print detailed submission records): git log-- stat

Format logs as required: git log-- pretty=short or git log-- graph-- pretty=oneline

Log sorting: git log-- pretty=format:'%h:%s'-- topo-order-- graph

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

Internet Technology

Wechat

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

12
Report