[英]GitHub 'push branch to server' button does what?
我拉下了我們的GitHub倉庫之一的master分支(沒有分叉),從命令行分支,做了一些工作,添加了+ commit,然后重新建立了master的基礎。
當我從命令行調用git push
,我收到一條消息,指出The current branch has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin my_branch.
The current branch has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin my_branch.
好吧,我看到那里提到“起源”,並且有點擔心這會以某種方式將我的更改推到master而不是my_branch
。 我是GitHub的新手,並認為應該安全使用它。
相反,我打開了適用於Windows客戶端的GitHub,在其中找到了我的分支,然后單擊“將分支推送到服務器”按鈕。 (至少我認為那是它的意思。)瞧,它奏效了。
單擊該按鈕在后台做了什么,因此我知道下一次要運行哪些命令?
它基本上做到了:
git checkout my_branch
git push origin my_branch
如果你這樣做
git push --set-upstream origin my_branch
每當您在分支機構中時,只需執行以下操作:
git push
它將自動轉到Github上的my_branch
分支。
可能類似於提到的命令git push origin my_branch
。
消息The current branch has no upstream branch.
意味着Git找不到與您新創建的分支關聯的遠程分支(這很有意義,遠程存儲庫中沒有這樣的分支)。
git push --set-upstream origin my_branch
意思是“獲取本地my_branch,在origin中找到my_branch並將更改上傳到該位置。還要將origin / my_branch設置為my_branch中git push的默認分支”。 因此,下次在檢出my_branch的情況下,您只需執行git push
並將更改上傳到適當的遠程分支。
man git push
有一些很好的說明性示例(以及其他git命令)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.