了解任务上下文中的git命令

问题描述 投票:-1回答:1

我需要帮助来了解git git pull / fetch merge等...我知道此站点上有很多文章和答案,因此我将其放在我遇到的问题的上下文中

  1. 所以,我有这个:

    Remote branch "myBranch"
    file A
    file B
    
    Local Branch "myBranch"
           file A
           file B 
    

此时,这两个分支相同

2。)我继续并在远程分支上手动创建一个附加文件。模仿其他开发者的承诺所以,图片变了

    Remote branch "myBranch"
    file A
    file B
    file C *

   Local Branch "myBranch"
           file A
           file B 

现在,我知道git fetch命令将“告诉我”有更改,但不会修改我的本地分支。当我运行git fetch时,得到以下输出

    $ git fetch
    remote: Counting objects: 4, done.
    remote: Compressing objects: 100% (3/3), done.
    remote: Total 4 (delta 1), reused 0 (delta 0), pack-reused 0
    Unpacking objects: 100% (4/4), done.
    From https://bvdevgithubvm.broadviewnet.com/internal-dev/bvn-process-history-service
       0c075bc..6098e63  prototype  -> origin/prototype

但是!我只知道有区别。我怎么知道发生了什么变化。在将其带到本地分支(到本地计算机)之前,可以在远程分支上看到更改吗?我想,我要寻找的是,如果您了解SVN世界,就相当于能够在执行SVN更新之前查看svn日志并查看谁提交了什么内容。

这是我所提出问题的第1部分。现在转到第2部分,可以将其视为独立问题。

3。)因此,从上面我调用git pull并将远程修改带到本地分支所以,现在的图片是

Remote branch "myBranch"
           file A
           file B
           file C

        Local Branch "myBranch"
           file A
           file B
           file C

此时分支是相同的。

所以,我继续从本地分支删除文件C。然后,我提交更改,但不要推送。 (还)!

此时图片是这样的:

    Remote branch "myBranch"
           file A
           file B
           file C

        Local Branch "myBranch"
           file A
           file B

现在,这是我感到困惑的地方。如果我执行git fetch或git pull,输出是

$ git pull
    Already up to date.

我希望知道远程分支上有某些东西使其与众不同。但是..我不能吗?我该如何处理?现在,我知道,与SVN(例如)相比,可能存在这种行为的原因,原因在于git filosophy。但是,我该如何处理这种差异?我怎么知道遥控器上的东西可能已经改变了?

git git-pull git-fetch
1个回答
0
投票

我认为您被困在svn世界中...您需要摆脱它,因为您对事物的看法会被破坏。

首先,不要以文件的形式来考虑...而是以修订版来考虑(因为这实际上是git起作用的。)

所以,第一个问题:

git diff --name-status remote/branchx # see what files changed
git diff remote/branchx # see the diff between both branches
git log HEAD remote/branchx # show the revisions that separate both branches

现在,关于您的第二个问题...。您的本地分支已经确定,但是...但是远程没有,因此,如果您尝试获取,则本地上的远程引用将不会移动repo DB(您的本地repo的远程指针已在此处设置)... git告诉您。

© www.soinside.com 2019 - 2024. All rights reserved.