---
# System prepended metadata

title: 為什麼要使用Github
tags: [theme]

---

---
tags: theme
title: 為什麼要使用Github
description: Use `{%hackmd BkVfcTxlQ %}` syntax to include this theme.
---

<style>

html, body, .ui-content {
    background-color: #333;
    color: #ddd;
}

body > .ui-infobar {
    display: none;
}

.ui-view-area > .ui-infobar {
    display: block;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    color: #ddd;
}

.markdown-body h1,
.markdown-body h2 {
    border-bottom-color: #ffffff69;
}

.markdown-body h1 .octicon-link,
.markdown-body h2 .octicon-link,
.markdown-body h3 .octicon-link,
.markdown-body h4 .octicon-link,
.markdown-body h5 .octicon-link,
.markdown-body h6 .octicon-link {
    color: #fff;
}

.markdown-body img {
    background-color: transparent;
}

.ui-toc-dropdown .nav>.active:focus>a, .ui-toc-dropdown .nav>.active:hover>a, .ui-toc-dropdown .nav>.active>a {
    color: white;
    border-left: 2px solid white;
}

.expand-toggle:hover, 
.expand-toggle:focus, 
.back-to-top:hover, 
.back-to-top:focus, 
.go-to-bottom:hover, 
.go-to-bottom:focus {
    color: white;
}


.ui-toc-dropdown {
    background-color: #333;
}

.ui-toc-label.btn {
    background-color: #191919;
    color: white;
}

.ui-toc-dropdown .nav>li>a:focus, 
.ui-toc-dropdown .nav>li>a:hover {
    color: white;
    border-left: 1px solid white;
}

.markdown-body blockquote {
    color: #bcbcbc;
}

.markdown-body table tr {
    background-color: #5f5f5f;
}

.markdown-body table tr:nth-child(2n) {
    background-color: #4f4f4f;
}

.markdown-body code,
.markdown-body tt {
    color: #eee;
    background-color: rgba(0, 0, 0, 0.5);
}

a,
.open-files-container li.selected a {
    color: #5EB7E0;
}


</style>

#### tags: `為什麼要使用Github` `tag2` `tag3` 
# Github 基礎教學

## 基本指令

### 本地操作指令

>`git init`－建立一個 repos

> `git add <file|path>`－將指定檔案或指定目錄下的所有檔案放入 stage
Ex. `git add .`

> `git reset -- <file>`－取消檔案的 stage

> `git reset --soft HEAD~1`－取消 1 個 commit

> `git checkout -- <file>`－重置檔案到上次 commit 的內容

> `git commit -m "<message>"`－將 stage 中的檔案進行 commit 且註記 message
Ex. `git commit -m "first commit"`


### 遠端操作指令

> `git clone <url>`－下載遠端的 repos

> `git remote <remote> <url>`－建立 remote
Ex. `git remote origin https://github.com/JuntTeng1113/xxxx.git`

> `git push <remote> <branch>`－將 remote 中之前 commit 過的內容上傳到 github 中指定的 branch
使用參數：`-u` 設定為預設值
第一次使用 `git push -u origin master`
下次使用 `git push`等同使用上述指令


### 一般指令
`git status`－查看目錄下的所有檔案狀態（只顯示與上次commit狀態不同的檔案）

`git log`－查看紀錄

`git remote`－列出所有 remote

![](https://i.imgur.com/niYUZKC.png)


## 參考資料
[【git教學 #1】15分鐘學會git & github（附實例）](https://www.youtube.com/watch?v=Zd5jSDRjWfA)
[【git教學 #2】搭配vscode使用更簡單！git reset & git checkout（CC字幕）](https://www.youtube.com/watch?v=TjHslMeJ81k)
[【git教學 #3】conflicts(衝突)是什麼？如何處理？（CC字幕）](https://www.youtube.com/watch?v=B-SZqdlU59g)
[【git教學 #4】git branch一次學會：branch, pull request, merge, rebase（CC字幕）](https://www.youtube.com/watch?v=P-nbNgIzlYE)
[【git】如何寫好的commit訊息](https://www.youtube.com/watch?v=g9-X6fR2eYA)