本地使用git:
創建並進入一個目錄,mkdir learn-git, cd learn-git
創建git倉庫:git init
添加文件到倉庫:git add readme.txt
提交文件到倉庫:git commit -m "write a readme file"
查看提交日誌:git log
退回上一版本: git reset --hard HEAD^
查看歷史commit ID:git reflog
退回指定版本:git reset --hard commit-ID
Git鼓勵大量使用分支:
查看分支:git branch
創建分支:git branch <name>
切換分支:git checkout <name>
創建+切換分支:git checkout -b <name>
合併某分支到當前分支:git merge <name>
刪除分支:git branch -d <name>
查看工作區狀態:git status
臨時存儲工作現場:git stash
查看臨時工作現場:git stash list
恢復工作現場(恢復並刪除stash內容);git stash pop
恢復工作現場(僅恢復,不刪除stash內容): git stash apply
刪除stash內容:git stash drop
如存在多個stash內容的時候,使用 git stash apply stash@{0}
git 查看遠程庫 git remote 或者 git remote -v