1. 程式人生 > >番外:如何給github上的開源專案貢獻程式碼?

番外:如何給github上的開源專案貢獻程式碼?

此番操作,對於已經貢獻過的來說很easy,對於從來沒有玩過的人來說,有點懵逼。

ok, 教學開始。~

舉個例子:比如你看到LogUtils庫,想為這個庫貢獻程式碼。那麼大體的操作步驟如下:

  • 1 克隆他的專案。[email protected]:pengwei1024/LogUtils.git
    • shell 命令: git clone xlog [email protected]:pengwei1024/LogUtils.git # clone 目標倉庫
  • 2 fork 他的專案,然後 給本地專案新增fork的遠端倉庫
    • shell 命令:git remote add myfork
      [email protected]
      :pythoncat1024/LogUtils.git # add 自己的遠端倉庫
  • 3 在本地建立新分支,並在新分支上面修改提交。
    • 大致操作可以是這樣子的:
git checkout -b frature
vi .gitignore
git add .
git commit -m "add a new feature"
git push -u origin feature
  • 4 去github上面,自己的專案裡去執行pull request操作。
  • 5 等待目標庫的維護者給你合入程式碼就好了。