88
99閱讀文章和觀看教學會有所幫助。不過,有什麼方法能比在不會弄亂任何東西的情況下,實際動手做來得更好?本項目旨在指導初學者及簡化初學者參與開源的方式。記住:過程越輕鬆,學習效益越高。如果妳/你想要做出第一次貢獻,只需按照以下簡單步驟操作即可。跟你保證,這會很好玩 :)
1010
11- #### _ 如果你不喜歡使用指令列,[ 這裡有使用圖形界面工具的教學。] ( #使用其他工具的教學 ) _
11+ _ 如果你不喜歡使用指令列,[ 這裡有使用圖形界面工具的教學。] ( #使用其他工具的教學 ) _
1212
1313<img align =" right " width =" 300 " src =" https://firstcontributions.github.io/assets/Readme/fork.png " alt =" fork this repository " />
1414
15- 如果你的電腦上尚未安裝 git,請按照這個[ 安裝指南(英文)] ( https://help.github.com/articles/set-up-git/ ) 進行安裝。
15+ #### 如果你的電腦上尚未安裝 git,請按照這個[ 安裝指南(英文)] ( https://help.github.com/articles/set-up-git/ ) 進行安裝。
1616
1717## 分叉(Fork)本儲存庫
1818
2323
2424<img align =" right " width =" 300 " src =" https://firstcontributions.github.io/assets/Readme/clone.png " alt =" clone this repository " />
2525
26- 接下來,將複製後的儲存庫複製到你 /妳的電腦上。點選圖示中的綠色按鈕,接著點選複製到剪貼簿按鈕 (將儲存庫網址複製下來)
26+ 接下來,將分叉後的儲存庫複製到你 /妳的電腦上。前往你/妳的GitHub帳號,打開分叉到帳號下的儲存庫, 點選圖示中的綠色按鈕,接著在SSH分頁上點選 * 複製到剪貼簿 * 按鈕 (將儲存庫網址複製下來)。
2727
2828隨後打開命令列視窗,輸入如下 git 命令:
2929
@@ -38,23 +38,23 @@ git clone "url you just copied"
3838譬如:
3939
4040``` bash
41- git clone https:// github.com/ < this-is-you> /first-contributions.git
41+ git clone git@ github.com: this-is-you/first-contributions.git
4242```
4343
44- ' this-is-you' 指的就是你/妳的 GitHub 用戶名。這一步會將你/妳的 first-contributions 儲存庫複製到你的電腦上。
44+ ` this-is-you ` 指的就是你/妳的 GitHub 用戶名。這一步會將你/妳的 first-contributions 儲存庫複製到你的電腦上。
4545
4646## 新建一個分支(Branch)
4747
48- 下面的命令能在命令行窗口中,把目錄切換到 first-contributions。
48+ 下面的命令能在命令行窗口中,把目錄切換到 first-contributions(如果你/妳尚未切換到該目錄):
4949
5050``` bash
5151cd first-contributions
5252```
5353
54- 接下來使用 ` git switch ` 命令建立一個程式碼分支 :
54+ 接下來使用 ` git switch ` 命令建立一個分支 :
5555
5656``` bash
57- git switch -c < add- your-name>
57+ git switch -c your-new-branch- name
5858```
5959
6060譬如:
@@ -65,48 +65,77 @@ git switch -c add-david
6565
6666(新分支的名稱不一定需要有 _ add_ 。然而,在這個新分支的名稱加入 _ add_ 是一件合理的事情,因為這個分支的目的是將妳/你的名字添加到貢獻者列表中。)
6767
68+ <details >
69+ <summary > <strong >如果在使用 git switch 命令的過程中出現錯誤(error),點擊這裡:</strong > </summary >
70+
71+ 如果顯示錯誤訊息 "Git: ` switch ` is not a git command. See ` git –help ` ",這可能是因為你/妳使用的是舊版的 git。
72+
73+ 在這種情況下,請改為使用 ` git checkout ` 命令:
74+
75+ ``` bash
76+ git checkout -b your-new-branch-name
77+ ```
78+
79+ </details >
80+
6881## 對程式碼進行修改,然後提交 (Commit) 修改
6982
70- 使用妳/你喜歡的編輯器打開 ` Contributors.md ` 這個文件,將自己的名字加在檔案最下面,然後存檔。在命令窗口執行 ` git status ` ,這會列出被更動的文件。接著 ` git add ` 這命令則可以添加更動項目到分支裡,就像以下這條命令 。
83+ 使用妳/你喜歡的編輯器打開 ` Contributors.md ` 這個文件,將自己的名字加在檔案中,不要將其添加到文件的開頭或結尾。將其新增至文件中間的任意位置,然後存檔 。
7184
7285<img align =" right " width =" 450 " src =" https://firstcontributions.github.io/assets/Readme/git-status.png " alt =" git status " />
7386
87+ 在命令窗口執行 ` git status ` ,這會列出被更動的文件。
88+
89+ 接著 ` git add ` 這命令則可以添加更動項目到分支裡,就像以下這條命令:
90+
7491``` bash
7592git add Contributors.md
7693```
7794
78- 現在就可以使用 ` git commit ` 命令 commit(提交)你/妳的修改了。
95+ 現在就可以使用 ` git commit ` 命令 commit(提交)你/妳的修改了:
7996
8097``` bash
81- git commit -m " Add < your-name> to Contributors list"
98+ git commit -m " Add your-name to Contributors list"
8299```
83100
84- 將 ` < your-name> ` 替換為自己的名字
101+ 將 ` your-name ` 替換為自己的名字。
85102
86103## 將更動發佈(Push)到 GitHub
87104
88- 使用 ` git push ` 命令發佈代碼
105+ 使用 ` git push ` 命令發佈代碼:
89106
90107``` bash
91- git push origin < add- your-name>
108+ git push -u origin your-branch- name
92109```
93110
94- 將 ` <add- your-name> ` 替換為之前新建的分支名稱。
111+ 將 ` your-branch- name ` 替換為之前新建的分支名稱。
95112
96113<details >
97- <summary > <strong >如果在發佈(push)過程中出錯誤 (error),點擊這裡</strong > </summary >
114+ <summary > <strong >如果在發佈(push)過程中出現錯誤 (error),點擊這裡: </strong > </summary >
98115
99116- ### 身份驗證錯誤(Authentication Error)
100117 <pre >remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
101118 remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
102- fatal: Authentication failed for 'https://github.com/< your-username >/first-contributions.git/'</pre >
119+ fatal: Authentication failed for 'https://github.com/& lt ; your-username>/first-contributions.git/'</pre >
103120 去 [ GitHub's tutorial] ( https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account ) 學習如何生成新的 SSH 密匙以及配置。
104121
122+ 此外,你/妳可能需要執行 'git remote -v' 來檢查遠端儲存庫的URL。
123+
124+ 如果看起來與這樣有一點相似:
125+
126+ <pre >origin https://github.com/your-username/your_repo.git (fetch)
127+ origin https://github.com/your-username/your_repo.git (push)</pre >
128+
129+ 使用以下命令更改它:
130+ ``` bash
131+ git remote set-url origin git@github.com:your-username/your_repo.git
132+ ```
133+ 否則,你/妳仍會收到要求輸入使用者名稱和密碼的提示,並出現身份驗證錯誤。
105134</details >
106135
107136## 提出 Pull Request 將你/妳的修改供他人審閱
108137
109- 前往先前自己 Fork 的 GitHub 儲存庫 ,會看到一個 ` Compare & pull request ` 的按鈕,點選該按鈕。
138+ 前往你/妳的GitHub帳號,打開分叉到帳號下的儲存庫 ,會看到一個 ` Compare & pull request ` 的按鈕,點選該按鈕。
110139
111140<img style =" float : right ;" src =" https://firstcontributions.github.io/assets/Readme/compare-and-pull.png " alt =" create a pull request " />
112141
@@ -119,18 +148,13 @@ git push origin <add-your-name>
119148
120149## 下一步?
121150
122- 在[ 這個網站] ( https://firstcontributions.github.io/#social-share ) 慶祝妳/你的成就並跟朋友及追隨者分享。
123-
124- 如果你想要更多練習,請看 [ code contributions] ( https://github.com/roshanjossey/code-contributions ) 。
125-
151+ 恭喜!妳/你剛剛完成了作為一個貢獻者會經常使用的標準工作流程:_ fork -> clone -> edit -> pull request_ !
126152
127- 恭喜!妳/你剛剛完成了作為一個貢獻者會經常使用的標準工作流程:fork -> clone -> edit -> pull request!
153+ 在 [ 這個網站 ] ( https://firstcontributions.github.io/#social-share ) 慶祝妳/你的貢獻並跟朋友及追隨者分享。
128154
129- 現在讓我們一起為其他專案做出貢獻吧!
130-
131- 我們整理了一份有簡單議題的專案清單來幫助你開始貢獻。
132- [ 去看看吧!] ( https://firstcontributions.github.io/#project-list )
155+ 如果你想要更多練習,請看 [ code contributions] ( https://github.com/roshanjossey/code-contributions ) 。
133156
157+ 現在就動手為其他專案貢獻你/妳的心力。我們整理了一個清單,裡面的專案都有簡單的議題可以著手。[ 去看看吧!] ( https://firstcontributions.github.io/#project-list )
134158
135159### [ 更多資料 ] ( ../additional-material/git_workflow_scenarios/additional-material.md )
136160
0 commit comments