# 使用github教學 part 3 ###### contributer: `kevinbird61` ###### tags: `github` `tutorial` `nckutechteam` ## Git clone - How to git clone branch of target repo? ```shell=bash > git clone <target-url> --branch <target-branch> ``` - And save git clone repo into specific-directory ```shell=bash > git clone <target-url> <target-dir> ``` ## Git fork sync with master? - step 1: add remote repository as our remote ``` > git remote add <defined-remote name> <..remote repo URL..> ``` - step 2: make sure you're in master ``` > git checkout master ``` - step 3: fetch and pull from master **to update your code** ``` > git pull <defined-remote name> master ``` - If you want to avoid unnecessary merge : - `git pull --rebase <defined-remote name> master` ## Delete Remote branch - 直接 delete 掉 `remote` 端! ``` > git push origin --delete <branch_name> ``` ## Merge remote branch - [link](https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging) - 假設現在有個 `hotfix` 的開發中 branch,並且要 merge `master` 的 branch ``` > git checkout master // 先過到 master > git merge hotfix // 對 hotfix 的更新元件 merge 到 master ``` - **git mergetool** : 作為一個 GUI mode 的 Merge ## Reset - Link: https://old-oomusou.goodjack.tw/git/remove-stage/