美文网首页
Day 12 : Git & Github 學習筆記(二)

Day 12 : Git & Github 學習筆記(二)

作者: YNC再寫一篇 | 来源:发表于2017-12-15 11:39 被阅读0次

    取消索引

    把提交的檔案拿回來自己的工作目錄中

    • 全部取消索引 :git reset HEAD
    • 單一檔案取消索引 :git reset HEAD 檔案名稱

    還原檔案

    • git checkout 檔案名稱
      將單一檔案還原到最新一版commit的狀態

    • git reset --hard
      把索引資料或任何編輯資料清空,讓工作區回到最後一次commit的狀況

    Github 遠端repository

    • 從遠端拉回本地 git clone


      git clone
    • git push 把本地的更新的資料推回遠端repository

    branch 分支

    HEAD知道自己在哪個commit紀錄
    新增第一個commit之後才會有master , master是最新的版本

    • git branch 瀏覽目前分支
    • git checkout (commit編號前4碼 )
      這時候去看檔案就會看到當時版本的狀態
    • git checkout master回到master
      (用git checkout 分支名來切換自己要到哪個分支)
    • 創建分支 git branch 分支名稱

    master 跟 branch 合併

    • 在 branch 做好檔案確認沒問題之後
    • 先 checkout 到 master 用 master 去合併分支
    • 在 master 輸入git merge 要合併的分支名

    以上是看著六角學院-掌握 Git & Github 程式時光機 這個課程學的。

    相关文章

      网友评论

          本文标题:Day 12 : Git & Github 學習筆記(二)

          本文链接:https://www.haomeiwen.com/subject/layrwxtx.html