“git pull”之间的区别从原点拉动命令? [英] Differences between "git pull" commands when pulling from origin?

查看:147
本文介绍了“git pull”之间的区别从原点拉动命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这些命令之间有什么区别?:


$ b

 #1 
git拉
#2
git拉原点
#3
git拉原点大师
#4
git拉原点/主
#5
git pull origin HEAD:master


解决方案

git pull 是一个方便的命令,它同时做着不同的事情。基本上它只是 git fetch 的组合,它连接到远程仓库并获取新的提交,并且 git merge (或 git rebase ),它将新提交合并到本地分支中。由于涉及到两个不同的命令,所以 git pull 的含义并不总是显而易见的。



您可以配置上游为当地分支。新鲜克隆后,您将有一个本地分支主,一个远程起源,您的主分支具有起源/主作为上游。
我假设下面这个设置。 (你可以通过 git branch -vv 或通过查看.git / config来查看你的上游配置。)



现在提出您的问题:
$ b $ ol

  • git pull = git获取来源 + git merge origin / master (或任何您的上游)

  • git pull origin = git pull (只要origin是您的上游远程) code> git pull origin master = git fetch origin master + git merge FETCH_HEAD

  • git pull origin / master :除非您有一个名为origin / master的远程计算机,否则无效
  • git pull origin HEAD:master :尝试直接将本地主设备重置为HEAD指向原点的任何设备。 (不要这样做。)


  • What are the differences between these commands?:

    # 1
    git pull
    # 2
    git pull origin
    # 3
    git pull origin master
    # 4
    git pull origin/master
    # 5
    git pull origin HEAD:master
    

    解决方案

    git pull is a convenience command, which is doing different things at the same time. Basically it is just a combination of git fetch, which connects to the remote repository and fetches new commits, and git merge (or git rebase) which incorporates the new commits into your local branch. Because of the two different commands involved the meaning of git pull is not always obvious.

    You can configure an upstream for a local branch. After a fresh clone you will have a local branch "master", a remote "origin" and your master branch has "origin/master" as upstream. I assume this setup below. (You can see your upstream configuration with git branch -vv or by looking at .git/config.)

    Now for your questions:

    1. git pull= git fetch origin + git merge origin/master (or whatever your upstream is)
    2. git pull origin = git pull (as long as origin is your upstream remote)
    3. git pull origin master = git fetch origin master+git merge FETCH_HEAD
    4. git pull origin/master : invalid unless you have a remote called "origin/master"
    5. git pull origin HEAD:master : Tries to directly reset you local master to whatever HEAD points to on origin. (Don't do this.)

    这篇关于“git pull”之间的区别从原点拉动命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆