Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Common commands of git (1)

Shulou Source: shulou.com Published: 2022-06-03 06:12:38 10月02日 Update

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

Tags: Warehouse branch file log command content storage area two location server format status directory conflict switch synchronization sorting service statistics configuration Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Microsoft MariaDB Apple Shulou Technology