EuDs

EuDs

EuDs's Blog
twitter
github

git學習筆記

git 學習筆記#

使用技巧#

Github 專案內搜尋#

在倉庫頁面上按 T ,然後直接輸入檔案名稱


記錄#

Gitee 配置的記錄#

因為 srtp 專案是用 gitee 作托管,所以今天試著配置了下 Gitee,還是花了些時間的,記錄如下:

  1. 主要參考的是Git 同時配置 Gitee 和 GitHub,但它上面第一步就是讓清除 git 的全局設置,有點不敢,因為怕清除後自己之前設置的一些東西出錯。
  2. 又看了幾個教程,發現Github 與 Gitee 共存配置上並沒有說要清楚全局設置,於是就跟著上面的一步步走,很順利地就設置好了。
  3. 一個收穫是config,id_rsa都是可以用記事本打開並編輯的。

多人協作時的流程#

這次小組專案用的是華為雲,所以流程也都是基於華為雲來說的。

對 remote branch 的認識#

There are potentially three versions of every remote branch:

  1. The actual branch on the remote repository
  2. The snapshot of that branch locally
  3. A local branch that might be tracking the remote branch

常用命令#

add#

  • git add . 會根據。gitignore 做過濾
  • git add * 會忽略。gitignore 把任何檔案都加入

推送#

檔案推送的三個步驟:

查看狀況#

git status

分支#

  • 轉到另一個分支 git checkout {分支名稱}

  • 查看本地分支 git branch

  • 查看遠端分支 git branch -r

  • 查看本地和遠端分支 git branch -a

  • 刪除本地分支 git branch -d {本地分支名稱}

  • 強制刪除本地分支git branch -D {本地分支名稱}

  • 刪除遠端分支 git push origin --delete {遠端分支名稱}

  • 已經刪除的遠端分支但仍git branch -a時仍顯示 :git remote prune origin

日誌#

  • git log 查看分支提交歷史
  • git reflog 也是查看日誌,主要區別是會顯示reset --hard

程式碼回退#

  • git reset --hard {commit_id}
  • git reset --hard HEAD^ 回退到上一版本

錯誤與解決#

  1. 錯誤:

    Updates were rejected because the remote contains work that you donot have locally.

    • 場景: 在嘗試 gitee 的時候,先是建了個遠端倉庫。然後在本地新建了個同名的資料夾,然後

    在資料夾裡新建了個檔案,push的時候報的錯

    • 解決: 根據下方的提示,是我沒有先pull,本地檔案不是最新的。
  2. Updates were rejected because the tip of your current branch is behind its remote counterpart

    • 場景時報錯,大意是網路問題
    • 解決

可供參考的連結#

載入中......
此文章數據所有權由區塊鏈加密技術和智能合約保障僅歸創作者所有。