倉庫相關:
查看遠程倉庫中的所有地址
git remote -v
分支相關:
查看全部分支
git branch -a
新建一個分支,但依然停留在當前分支$ git branch [branch-name]
新建一個分支,並切換到該分支$ git checkout -b [branch]
新建一個分支,指向指定commit $ git branch [branch] [commit]
新建一個分支,與指定的遠程分支建立追蹤關係
git branch --track [branch] [remote-branch]
合併指定分支到當前分支
git merge [branch]
選擇一個commit,合併進當前分支
git cherry-pick [commit]
刪除分支$ git branch -d [branch-name]
刪除遠程分支
git push origin --delete [branch-name]
git branch -dr [remote/branch]
git log --pretty=oneline:查看Git版本提交信息,值只顯示版本唯一HEAD和提交備註信息(是Git log的簡版),後提交的在上面;
Git reset --hard HEAD:回滾到指定的版本,HEAD對應爲版本的唯一ID號(HEAD ID可以只寫前6位)。
Git reset --hard HEAD^:回滾到上一個版本
Git reflog
如果在回退以後又想再次回到之前的版本,git reflog 可以查看所有分支的所有操作記錄(包括commit和reset的操作),包括已經被刪除的commit記錄,git log則不能察看已經刪除了的commit記錄。
緩存操作相關
git rm
$ git rm [file1] [file2] ...
刪除工作區文件,並且將這次刪除放入暫存區
歷史操作記錄相關
git log
查看當前倉庫基本信息。
git remote show origin