每次開新 Project 第一件事必先是要去 GitHub 開一個 Repository 先,然後先會在 Local 開一個資料夾再用 git init 開始,但是因為常常使用 GUI 所以忘記了 Command... 這次來個整合記錄一下。 ### 開始工作 正如上面所說,使用 `git init` 當然是不少得 ! ```sh # create new project folder $ mkdir my_project # change directory to new project folder $ cd my_project # git init $ git init ``` ### 加入 Remote 到你的本機 Git 項目內 接下來就要把你 GitHub 的 URL 加入到 git 內,我們可以使用 `git remote add` 來達成。 `git remote add` 會接受兩個參數。 - 名稱,例如 `origin` - URL,例如 `https://github.com/user/repo.git` ```sh # add remote $ git remote add origin https://github.com/user/repo.git # verify remote $ git remote -v > origin https://github.com/user/repo.git (fetch) > origin https://github.com/user/repo.git (push) ``` ### 從 GitHub 抓取資料 之後應該不難了,因為可以使用 GUI 介面去處理。或是可以使用 `git pull` 來抓取 remote 上的資料。 `git pull` 會接受兩個參數。 - 名稱,例如 `origin` - 分支的名稱,例如 `master` ```sh # fetch project $ git pull origin master ``` 然後改改 README.md,再 Create new Branch 為 `develop`,然後 `commit` 再 `push`。這樣就可以開始依照 Git Flow 開發你的項目了 !