国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

git push -u參數(shù)是什么意思?

這篇具有很好參考價(jià)值的文章主要介紹了git push -u參數(shù)是什么意思?。希望對大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

背景

git push的時(shí)候,有時(shí)候會用-u參數(shù),有時(shí)候不適用。這是為什么呢?

官方解釋

-u

--set-upstream

For every branch that is up to date or successfully pushed, add upstream (tracking) reference, used by argument-less git-pull(1) and other commands. For more information, see branch.<name>.merge in git-config(1).

branch..merge
Defines, together with branch..remote, the upstream branch for the given branch. It tells git fetch/git pull which branch to merge and can also affect git push (see push.default). When in branch , it tells git fetch the default refspec to be marked for merging in FETCH_HEAD. The value is handled like the remote part of a refspec, and must match a ref which is fetched from the remote given by “branch..remote”. The merge information is used by git pull (which at first calls git fetch) to lookup the default branch for merging. Without this option, git pull defaults to merge the first refspec fetched. Specify multiple values to get an octopus merge. If you wish to setup git pull so that it merges into from another branch in the local repository, you can point branch..merge to the desired branch, and use the special setting . (a period) for branch..remote.

實(shí)戰(zhàn)

當(dāng)在gitlab上初始化一個(gè)項(xiàng)目的時(shí)候,通常會給你一些git提升
例如

Git 全局設(shè)置
git config --global user.name "Administrator"
git config --global user.email "ninesun@126.com"
創(chuàng)建一個(gè)新倉庫
git clone ssh://git@k8s-22.host.com:30401/myysophia/git-flight-rules.git
cd git-flight-rules
git switch -c main
touch README.md
git add README.md
git commit -m "add README"
git push -u origin main
推送現(xiàn)有文件夾
cd existing_folder
git init --initial-branch=main
git remote add origin ssh://git@k8s-22.host.com:30401/myysophia/git-flight-rules.git
git add .
git commit -m "Initial commit"
git push -u origin main
推送現(xiàn)有的 Git 倉庫
cd existing_repo
git remote rename origin old-origin
git remote add origin ssh://git@k8s-22.host.com:30401/myysophia/git-flight-rules.git
git push -u origin --all
git push -u origin --tags

-u 參數(shù)相當(dāng)于是讓你本地的倉庫和遠(yuǎn)程倉庫進(jìn)行了關(guān)聯(lián)。

git push -u origin --all

這代表是將本地已存在的git項(xiàng)目的所有分支推送到遠(yuǎn)程倉庫名為origin的倉庫。

git push -u origin main 只推送main分支到遠(yuǎn)程倉庫

還有另外一種情況,如下
我有兩個(gè)遠(yuǎn)程倉庫,一個(gè)內(nèi)網(wǎng)一個(gè)外網(wǎng)的。
這是提交的時(shí)候就需要很明確的知道你需要把本地的哪個(gè)分支推送到遠(yuǎn)程倉庫的哪個(gè)分支。
git push -u參數(shù)是什么意思?

下面這兩個(gè)push操作你應(yīng)該就知道是什么意思了吧
git push -u main main

git push -u origin master

有時(shí)候你git push不帶u參數(shù)后,git pull (不帶參數(shù))會報(bào)錯(cuò)

You asked me to pull without telling me which branch you
want to merge with, and 'branch.test.merge' in
your configuration file does not tell me, either. Please
specify which branch you want to use on the command line and
try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details.

If you often merge with the same branch, you may want to
use something like the following in your configuration file:

    [branch "test"]
    remote = <nickname>
    merge = <remote-ref>

    [remote "<nickname>"]
    url = <url>
    fetch = <refspec>

See git-config(1) for details.

這是因?yàn)槟銢]有把你本地的分支和遠(yuǎn)程沒有關(guān)聯(lián)。要么使用git push -u 遠(yuǎn)程倉庫名 本地分支名。 要么git pull的時(shí)候使用-u同樣生效文章來源地址http://www.zghlxwxcb.cn/news/detail-430145.html

到了這里,關(guān)于git push -u參數(shù)是什么意思?的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • M330左鍵有時(shí)候按下沒反應(yīng)的解決 - 換微動

    羅技M330鼠標(biāo)左鍵有時(shí)候按下沒反應(yīng),原因是微動老了要換新的了。 1、電烙鐵/錫條(最主要的是這兩個(gè),其他可以不需要,操作電烙鐵時(shí)候一定要小心,不要碰到被燙到) 2、小號螺絲刀,給眼鏡用的那種,用來拆鼠標(biāo)的螺絲(共2個(gè)螺絲) 視頻教程: https://www.bilibili.com/vi

    2024年02月09日
    瀏覽(100)
  • git push -u參數(shù)是什么意思?

    git push -u參數(shù)是什么意思?

    git push的時(shí)候,有時(shí)候會用-u參數(shù),有時(shí)候不適用。這是為什么呢? branch..merge Defines, together with branch..remote, the upstream branch for the given branch. It tells git fetch/git pull which branch to merge and can also affect git push (see push.default). When in branch , it tells git fetch the default refspec to be marked for merg

    2024年02月01日
    瀏覽(16)
  • 在Android Studio導(dǎo)入一個(gè)項(xiàng)目之后,通常需要下載Gradle的相應(yīng)版本,但是AS的自動下載很慢,有時(shí)候甚至?xí)?。會出現(xiàn)類似Error:connect time out等錯(cuò)誤...

    在Android Studio導(dǎo)入一個(gè)項(xiàng)目之后,通常需要下載Gradle的相應(yīng)版本,但是AS的自動下載很慢,有時(shí)候甚至?xí)?。會出現(xiàn)類似Error:connect time out等錯(cuò)誤...

    用Android Studio導(dǎo)入一個(gè)項(xiàng)目時(shí),用Gradle構(gòu)建過程中報(bào)錯(cuò)誤,估計(jì)是下載gradle.zip文件時(shí)訪問不到,應(yīng)該是被墻了,網(wǎng)速太慢,下載不了外網(wǎng)資源。錯(cuò)誤有如下情況:1、加載過慢2、下載超時(shí)3、下載失敗 解決方法如下: 1、下載對應(yīng)的gradle版本 在Project的視圖下,找到gradle,里面的

    2024年02月03日
    瀏覽(104)
  • 后端請求的時(shí)候返回的狀態(tài)碼有幾種,代表什么意思

    ?????????2xx表示成功處理了請求,200請求已完成,202服務(wù)器接收未處理,204、205:服務(wù)器處理了但是沒有任何返回,206:處理了部分get請求 ? ? ? ? 3xx請求被重定向,需要進(jìn)一步操作 ????????4xx:請求碼出錯(cuò)影響了請求,400:服務(wù)器不理解,401:要求身份驗(yàn)證,404:

    2024年02月12日
    瀏覽(17)
  • 【git報(bào)錯(cuò)】git push時(shí)候報(bào)錯(cuò)fatal: unable to access ‘http://xxxxxxxxxxxx.git/‘: Failed to connet to xxxxx

    【git報(bào)錯(cuò)】git push時(shí)候報(bào)錯(cuò)fatal: unable to access ‘http://xxxxxxxxxxxx.git/‘: Failed to connet to xxxxx

    在執(zhí)行g(shù)it push origin master要把代碼推送到遠(yuǎn)程庫的時(shí)候出現(xiàn)了報(bào)錯(cuò):fatal: unable to access ‘http://xxxxxxxxxxxx.git/’: Failed to connet to xxxxx 先是在博客上(https://blog.csdn.net/cubejava/article/details/120631396)看到是說:一般是這是因?yàn)榉?wù)器的SSL證書沒有經(jīng)過第三方機(jī)構(gòu)的簽署,所以才報(bào)錯(cuò),

    2024年02月16日
    瀏覽(17)
  • git push 使用 --mirror 參數(shù)復(fù)制倉庫

    git push 使用 --mirror 參數(shù)復(fù)制倉庫

    遷移一個(gè) Git 倉庫并且保留原有的提交記錄和分支 克隆原始倉庫到本地?git clone 原始倉庫URL 新倉庫目錄 添加新的遠(yuǎn)程倉庫:git remote add new-origin? 新倉庫URL 推送所有分支和標(biāo)簽到新的遠(yuǎn)程倉庫: git push new-origin --mirror origin 是默認(rèn)的遠(yuǎn)程倉庫的名稱,它通常指向你最初克隆或

    2024年02月21日
    瀏覽(23)
  • Git在push推送的時(shí)候報(bào)錯(cuò):Donehint: not have locally. This is usually caused by another repository pushinghi

    為什么會出現(xiàn)這樣的錯(cuò)誤?:我是新建的項(xiàng)目在git上申請了一個(gè)倉庫,由于第一次推送 本地和遠(yuǎn)程倉庫兩者代碼文件不同步,因此需要先pull,進(jìn)行合并然后再進(jìn)行push。 解決方法: 1、先使用pull命令: 2、再使用push命令:

    2024年02月11日
    瀏覽(16)
  • Java 方法中參數(shù)類型后寫了三個(gè)點(diǎn)?什么意思?

    Java 方法中參數(shù)類型后寫了三個(gè)點(diǎn)?什么意思?

    4、兩個(gè)list,一個(gè)新的,一個(gè)舊的,舊列表中可能有新列表中存在的數(shù)據(jù),也可能存在新列表中不存在的數(shù)據(jù)(注:新舊列表中都不存在重復(fù)元素) 需要將新舊列表中數(shù)據(jù)區(qū)分成三部分:1、只存在舊列表中的2、只存在新列表中的3、新舊列表中都存在的 可以將舊列表中的元素

    2024年01月18日
    瀏覽(21)
  • 深度學(xué)習(xí)中epoch、batch、step、iteration等神經(jīng)網(wǎng)絡(luò)參數(shù)是什么意思?

    epoch: 表示將訓(xùn)練數(shù)據(jù)集中的所有樣本都過一遍 (且僅過一遍)的訓(xùn)練過程。在一個(gè)epoch中,訓(xùn)練算法會按照設(shè)定的順序?qū)⑺袠颖据斎肽P瓦M(jìn)行前向傳播、計(jì)算損失、反向傳播和參數(shù)更新。一個(gè)epoch通常包含多個(gè)step。 batch:一般翻譯為“批次”,表示一次性輸入模型的一組

    2024年02月10日
    瀏覽(30)
  • git中push和pull的區(qū)別是什么

    git中push和pull的區(qū)別: 1、“git push”命令是將本地庫中的最新信息發(fā)送給遠(yuǎn)程庫,用于將本地分支的更新,推送到遠(yuǎn)程主機(jī); 2、“git pull”命令是從遠(yuǎn)程獲取最新版本到本地庫,用于從另一個(gè)存儲庫或本地分支獲取并集成整合。 git push與git pull是一對推送/拉取分支的git命令。

    2024年02月03日
    瀏覽(15)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包