git push相關操作

$ git push ssh://[email protected]/rt4ls.git master // 把本地倉庫提交到遠程倉庫的master分支中

$ git remote add origin ssh://[email protected]/rt4ls.git
$ git push origin master


這兩個操作是等價的,第二個操作的第一行的意思是添加一個標記,讓origin指向ssh://[email protected] /rt4ls.git,也就是說你操作origin的時候,實際上就是在操作ssh://[email protected]/rt4ls.git。origin在這裏完全可以理解爲後者的別名。

注意:需要說明的是,默認情況下這條語句等價於提交本地的master倉庫到遠程倉庫,並作爲遠程的master分支。
如果想把本地的某個分支test提交到遠程倉庫,並作爲遠程倉庫的master分支,或者作爲另外一個名叫test的分支,那麼可以這麼做。

$ git push origin test:master // 提交本地test分支作爲遠程的master分支
$ git push origin test:test // 提交本地test分支作爲遠程的test分支

如果想刪除遠程的分支呢?類似於上面,如果:左邊的分支爲空,那麼將刪除:右邊的遠程的分支


$ git push origin :test // 剛提交到遠程的test將被刪除,但是本地還會保存的,不用擔心。
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章