天天看點

一文搞定github倉庫上傳維護

1 上傳項目

  1. 建立github倉庫
    一文搞定github倉庫上傳維護
  2. 項目檔案夾處打開git

    滑鼠右鍵git bash here即可。

  3. 初始化
$ git init
           
  1. 添加檔案到倉庫,.表示所有檔案,也可以指定單個檔案
  1. 上傳說明,引号内容自定
  1. 關聯遠端倉庫,遠端倉庫連結即上面建立的新倉庫位址
$ git remote add origin https://github.com/xxx/xxx.git
           
  1. 上傳到github
$ git push origin master:master
           

注:可能會報錯error: failed to push some refs to ‘https://github.com/xxx’,請先運作下面指令,再重複第7步

$ git pull origin master --allow-unrelated-histories
           

2 更新項目

  1. 合并遠端與本地倉庫
$ git pull origin master --allow-unrelated-histories
           
  1. 添加檔案到倉庫,.表示所有檔案,也可以指定單個檔案
  1. 上傳說明,引号内容自定
  1. 上傳到github
$ git push origin master:master