不常去contribute,所以老是忘記如何提交fix,特地重新記錄下,以免忘記。
1. Fork別人的代碼repo
2. clone自己的fork到本地,進行修改
在自己的Repositories裏面找到剛纔fork出來的Repo.
因爲畢竟不是原作者,要定期去update最新的代碼,所以最好不要直接提交到自己的master branch上,而是在github上單獨創建一個branch。
然後在右側找到SSH clone URL,在本地的命令行裏面執行
PS:
也可以直接在github上修改,然後頁面內Commit。量不大時,這樣做比較方便。只要網速給力……
3. 提交修改到github
git commit -a
git push
4. 創建pull request 讓作者codereview
點擊Pull Requests -> New pull request
點擊Edit
左側選取作者的master branch (一般是這樣,除非有單獨的branch給開發用),右側選自己的repo的新branch
再點擊 Click to create a pull request for this comparison 填入信息提交就OKl了。
5. Update 作者最新的代碼
同樣在自己的repo裏面,新建一個pull request,左側是自己的,右側是原作者的branch,創建後提交就OK了。
6. rollback repository到某個commit
github上有時我們想rollback某個branch到某個commit,直接在本地執行
git checkout <target_branch>
git reset --hard <commit_id>
git push -f