# Gitea 基本指令

**SSH金鑰**

```
```
cmd

ssh-keygen -t ed25519 -C "your_email@example.com"
```<button class="copy-the-code-button" data-style="button" title="複製至剪貼簿">Copy</button>
```

**id\_rsa.pub 貼入gitea web 新增ssh金鑰**

**更改預設分支名稱為master**

```
```
git config --global init.defaultBranch master
```<button class="copy-the-code-button" data-style="button" title="複製至剪貼簿">Copy</button>
```

**初始化git**

```
```
git init
```<button class="copy-the-code-button" data-style="button" title="複製至剪貼簿">Copy</button>
```

**加入檔案或目錄**

```
```
git add <檔案名稱>    #檔案
git add .            #整個目錄
```<button class="copy-the-code-button" data-style="button" title="複製至剪貼簿">Copy</button>
```

**加入版本資訊**

```
```
git commit -m "xxx"
```<button class="copy-the-code-button" data-style="button" title="複製至剪貼簿">Copy</button>
```

**設定資訊**

```
```
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
```<button class="copy-the-code-button" data-style="button" title="複製至剪貼簿">Copy</button>
```

**連接gitea**

```
```
git remote add <origin> <地址>  #設定名稱和gitea儲存庫地址

>>git remote add main  https://xxx.git
```<button class="copy-the-code-button" data-style="button" title="複製至剪貼簿">Copy</button>
```

**查詢remote**

```
```
git remote -v
```<button class="copy-the-code-button" data-style="button" title="複製至剪貼簿">Copy</button>
```

**上傳至儲存庫**

```
```
git push -u main master  #上傳至連接位置和分支
```<button class="copy-the-code-button" data-style="button" title="複製至剪貼簿">Copy</button>
```

**移除連接gitea**

```
```
git remote remove main  #移除連接
```<button class="copy-the-code-button" data-style="button" title="複製至剪貼簿">Copy</button>
```

**新增標籤**

```
git tag v1     #標籤
git push <origin> v1   #推送標籤至儲存庫
```