12月 16, 2019 Git Github
每次開新 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 開發你的項目了 !
過去文章
2025 (9)
4 (5)
3 (1)
2 (3)
2024 (25)
11 (3)
10 (3)
9 (1)
3 (18)
2022 (6)
10 (1)
6 (2)
5 (1)
3 (1)
1 (1)
2021 (21)
11 (7)
7 (1)
6 (2)
5 (2)
4 (6)
3 (2)
2 (1)
2020 (92)
12 (1)
11 (2)
10 (4)
9 (10)
8 (5)
7 (1)
6 (3)
5 (1)
4 (4)
3 (25)
2 (7)
1 (29)
2019 (57)
12 (25)
11 (7)
9 (25)