[TOC]
------
### 首先在碼云創建一個倉庫
<img src="https://gitee.com/codeyuany/TyporaImages/raw/master//images/image-20210831203305946.png" alt="image-20210831203305946" style="zoom: 67%;" />
> 創建好后拿到這個倉庫的地址:https://gitee.com/codeyuany/git.git
> 全局設置
>
> 首先可以在自己的本地環境中設置一下自己的一些個人信息
```shell
git config --global user.name "yong.yuan"
git config --global user.email "1218639030@qq.com"
```
> 設置好以后可以通過`config`相關的一些命令來查看一下已經配置好的信息。
```
[root@supman ~]# git config
usage: git config [options]
Config file location
--global use global config file
--system use system config file
--local use repository config file
-f, --file <file> use given config file
--blob <blob-id> read config from given blob object
Action
--get get value: name [value-regex]
--get-all get all values: key [value-regex]
--get-regexp get values for regexp: name-regex [value-regex]
--replace-all replace all matching variables: name value [value_regex]
--add add a new variable: name value
--unset remove a variable: name [value-regex]
--unset-all remove all matches: name [value-regex]
--rename-section rename section: old-name new-name
--remove-section remove a section: name
-l, --list list all
-e, --edit open an editor
--get-color <slot> find the color configured: [default]
--get-colorbool <slot>
find the color setting: [stdout-is-tty]
Type
--bool value is "true" or "false"
--int value is decimal number
--bool-or-int value is --bool or --int
--path value is a path (file or directory name)
Other
-z, --null terminate values with NUL byte
--includes respect include directives on lookup
```
> 例如獲取一下配置列表
```shell
[root@supman ~]# git config -l
user.name=yong.yuan
user.email=1218639030@qq.com
```
> 單獨獲取一項配置
```shell
[root@supman ~]# git config --get user.name
yong.yuan
```
### 初始化倉庫
> 創建一個文件夾,并初始化本地倉庫,添加遠程倉庫 - `remote`遠程、`origin`源頭
```shell
[root@supman ~]# mkdir git
[root@supman ~]# cd git
[root@supman git]# git init
Initialized empty Git repository in /root/git/.git/
[root@supman git]# git remote add origin https://gitee.com/codeyuany/git.git
```
> 在初始化倉庫后我們會發現文件夾里什么都沒有
```shell
[root@supman git]# ls
```
> 但是其實在文件夾里存在一個隱藏的`.git`文件
```shell
[root@supman git]# ls -al
total 12
drwxr-xr-x 3 root root 4096 Aug 31 20:57 .
dr-xr-x---. 9 root root 4096 Aug 31 20:56 ..
drwxr-xr-x 7 root root 4096 Aug 31 20:57 .git
```
> 這個文件里面存在的是各種git的各種信息,刪除這個`.git`文件后這個文件夾也就是個普通文件夾了
```shell
[root@supman git]# cd .git
[root@supman .git]# ls
branches config description HEAD hooks info objects refs
```
> 使用`git remote -v`可以看到本地倉庫關聯的遠程倉庫信息,就是我們剛才添加的遠程倉庫。
```shell
[root@supman .git]# git remote -vorigin https://gitee.com/codeyuany/git.git (fetch)origin
https://gitee.com/codeyuany/git.git (push)
```