常用Git指令

列出所有local, remote的分支
$ git branch -a

顯示遠端branch狀態
$ git remote show origin

更新遠端分支列表
$ git remote update origin –prune

Local間切換分支
$ git checkout <branch>

Local新建並切換分支
$ git checkout -b <branch>
從Remote新建並切換分支
$ git checkout -b <new_branch> origin/<remote_branch>

更新分支
$ git pull –ff-only
$ git pull origin <遠端分支名>:<本地分支名>
$ git pull origin <branch>
$ git pull origin <branch> –ff-only

設定 global config
$ git config –global user.name “John Doe”
$ git config –global user.email johndoe@example.com

列出所有config
$ git config –list

顯示最後一筆log
$ git log -p -1

顯示最後五筆格式化過的log
$ git log –pretty=format:”%h – %an, %ar : %s” -5

顯示log graph
$ git log –pretty=format:”%h %s” –graph

Reference

  • https://www.yiibai.com/git/git_pull.html
  • https://www.yiibai.com/git/git_remote.html
  • https://git-scm.com/book/zh-tw/v2/%E4%BD%BF%E7%94%A8-Git-%E5%88%86%E6%94%AF-%E5%88%86%E6%94%AF%E7%AE%A1%E7%90%86

Leave a Reply

avatar