Gitee的使用流程


Gitee的使用流程

1.Gitee的下載和安裝

默認配置點擊下一步安裝完畢

2.Gitee賬號的申請

  • 打開gitHub網站,http://github.com/
  • 注冊gitHub賬號
    1)點擊Sign Up
    2)填寫用戶名,郵箱,密碼。填寫完成點擊Create an account
    3)選擇第一個免費,Unlimited public repositories for free.然后點擊Continue

3.新建新的服務倉庫

3.創建本地倉庫

  • 如果是針對新服務倉庫的第一次操作(之前有過對別的倉庫的操作過),找到C盤->用戶->Adminisstrator->.ssh ,刪除.ssj文件夾

  • 找到空間大的盤,創建屬於自己的本地倉庫(新建一個文件夾,例如A)

  • 點進去本地倉庫A,右鍵,選擇Git Base Here,在出現的命令框中進行操作

  • 設置這個文件夾A成為自己的本地倉庫 git init,后會發現這個文件夾中出現了.git文件夾

  • 設置自己的賬戶名和郵箱,用戶名是git網址上點擊頭像后,可以看到,郵箱是注冊時用的
    1) git config --global user.name "用戶名"
    2) git config --global user.email "郵箱"

  • 設置公鑰 (設置后,針對這個倉庫,此電腦后面上傳文件可以不需要再次輸入賬號密碼)
    1)ssh-keygen -t rsa -C "gitHub上注冊時用的郵箱"
    2)一直回車,直到
    生成類似於下面的內容,公鑰已經生成
    +--[ RSA 2032]----+
    | .+ + |
    | ssssssss |
    | = * * |
    | o = + |
    | ssss . |
    | o oss |
    | o .sE |
    | |
    | |
    +-----------------+

  • 找到生成,找到.ssh文件夾(上面有路徑),用記事本打開.pub文件,復制里面內容

  • 打開git網址,找到自己倉庫,點擊管理———>添加公鑰——>把公鑰粘貼進去——>點擊確定

4.上傳項目到倉庫中

  • 在文件夾A中創建一個文件b.txt
  • 連接服務倉庫 git remote add origin "ssh/https地址"
  • 每次上傳前都要先跟新項目文件,第一次操作的跟新命令不一樣
    git pull --rebase origin master 會發現文件夾A下多了兩個文件,README.md README.en.md
  • 添加剛才創建的文件(b.txt)到本地倉庫 git add b.txt
  • 給剛才添加到本地倉庫的文件添加注釋 git commit -m "注釋"
  • 連接服務倉庫 git remote add origin "ssh/https地址" (這一步連接服務必須執行)
  • 上傳文件到服務倉庫 git push -u origin master
  • 下次上傳文件前 ,先拉取服務上的項目,和自己的合並(防止版本沖突),在上傳
    git pull origin master 拉取(和第一次的拉取不同)

5.從服務倉庫下載項目到自己本地倉庫

  • 自己創建的項目庫 git clone git@github.com:用戶名/倉庫名.git(ssh地址)
  • 別人創建好的項目
    1)點擊右上角的Fork,表示先復制到自己的倉庫里
    2)git clone git@github.com:用戶名/倉庫名.git

3.刪除分支

  • 刪除本地分支 git branch -d 分支名稱
  • 刪除遠端分支 git push origin --delete 遠程分支名稱

4.常見報錯

1.切換分支報錯

  • error: pathspec 'master' did not match any file(s) known to git
    解決:
  • git fetch 獲取所有遠端分支
    2.git push 報錯
  • error: failed to push some refs to 'git@gitee.com:one-piece-five/omini.git'
    hint: Updates were rejected because the tip of your current branch is behind
    hint: its remote counterpart. Integrate the remote changes (e.g.
    hint: 'git pull ...') before pushing again.
    hint: See the 'Note about fast-forwards' in 'git push --help' for details.
    解決
  • 先git pull origin master
  • 之后再git push


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM