美文网首页
git push -u 选项的作用

git push -u 选项的作用

作者: 苍老师的眼泪 | 来源:发表于2022-05-31 00:02 被阅读0次

带上-u 参数其实就相当于记录了push到远端分支的默认值,这样当下次我们还想要继续push的这个远端分支的时候推送命令就可以简写成git push即可。
如果从未设置过 push 的 -u 选项(之前的每一次 push 都使用 远程别名(可以通过 git remote -v 来查看远程别名)和分支名)而省略远程别名和分支名,则会报错:

fatal: The current branch main has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin main

相关文章

网友评论

      本文标题:git push -u 选项的作用

      本文链接:https://www.haomeiwen.com/subject/qyiaprtx.html