1. 程式人生 > >origin master 和 master,以及 push 命令

origin master 和 master,以及 push 命令


$ git branch -a (展示所有的git分支)

* master

  remotes/origin/HEAD -> origin/master

  remotes/origin/master

    ······

$ git branch -r (展示遠端分支)

  origin/HEAD -> origin/master

  origin/master

可以發現,master就是local branch,origin/master是remote branch

$ git diff origin/master master (可以看到兩者的不同)

git push origin master (省略了<dst>,等價於“git push origin master:master”,其中

origin指定了你要push到哪個remote)

我們一般寫的形式為“ git push origin <src>:<dst> ”,冒號前表示local branch的名字,冒號後表示remote repository下 branch的名字。注意,如果你省略了<dst>,git就認為你想push到remote repository下和local branch相同名字的branch。

$ git push origin :mybranch (在origin repository裡面查詢mybranch,刪除它。用一個空的去更新它,就相當於刪除了)


#重新整理遠端分支列表

git remote update origin --prune

參考自:http://lishicongli.blog.163.com/blog/static/1468259020132125247302/