Git结帐和远程跟踪误解了

时间:2017-04-20 09:18:31

标签: git

我需要解释Git对我来说有点新鲜。

我来自旧学校SVN,每个人都快点提交远程存储库,没有你知道的冲突......这一次结束了:)。

好吧,我用git做了三个命令:

1)

C:\webs\carrefour-france\crf-fra>git checkout -b fflbranche origin/dev-17.5-tma
Switched to a new branch 'fflbranche'
Branch fflbranche set up to track remote branch dev-17.5-tma from origin.

C:\webs\carrefour-france\crf-fra>git status
On branch fflbranche
Your branch is up-to-date with 'origin/dev-17.5-tma'.
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        crf-fra-core/src/main/documentation/diagramme.vpp.bak_000f
        crf-fra-core/src/main/documentation/diagramme.vpp.vbak
        crf-fra-core/src/main/documentation/diagramme.vux
        crf-fra-eshop-fo/src/main/documentation/diagrammes.vpp.bak_000f
        crf-fra-eshop-fo/src/main/documentation/diagrammes.vpp.vbak
        crf-fra-eshop-fo/src/main/documentation/diagrammes.vux
        src/main/documentation/Architecture.vpp.bak_000f
        src/main/documentation/Architecture.vpp.vbak
        src/main/documentation/Architecture.vux

nothing added to commit but untracked files present (use "git add" to track)

C:\webs\carrefour-france\crf-fra>

2)

C:\webs\carrefour-france\crf-fra>git branch --list
  dev-17.5
  dev-17.5-art04
* fflbranche
  master
  origin/dev-17.5

C:\webs\carrefour-france\crf-fra>

3)

C:\webs\carrefour-france\crf-fra>git remote show origin
Username for 'http://kazan.priv.atos.fr': a665145
Password for 'http://a665145@kazan.priv.atos.fr':
* remote origin
  Fetch URL: http://kazan.priv.atos.fr/git/crf-fra
  Push  URL: http://kazan.priv.atos.fr/git/crf-fra
  HEAD branch: master
  Remote branches:
    17.2-eligibilite           tracked
    dev-15.3.2-optimAdmin      tracked
    dev-16.0.1                 tracked
    dev-16.1-old               tracked
    ...(much more)
    stable-17.3-monitoringSF   tracked
    stable-17.3.1              tracked
    stable-CONF-ENV            tracked
    tmp-trunk                  tracked
  Local branches configured for 'git pull':
    dev-17.5       merges with remote dev-17.5
    dev-17.5-art04 merges with remote dev-17.5-art04
    fflbranche     merges with remote dev-17.5-tma
    master         merges with remote master
  Local refs configured for 'git push':
    dev-17.5       pushes to dev-17.5       (local out of date)
    dev-17.5-art04 pushes to dev-17.5-art04 (up to date)
    master         pushes to master         (local out of date)

我的问题是:

为什么在上一次输出中,在“为git push'配置的本地引用中:”部分它不会出现“fflbranche”。这是否意味着如果我修改本地分支上的文件,我无法将其推送到远程跟踪分支?

谢谢你的灯!

2 个答案:

答案 0 :(得分:0)

  

为什么在最后一次输出中,&#34;本地参考配置为&#39; git push&#39;:&#34;部分它没有出现&#34; fflbranche&#34;

我猜你还没有推到远程,所以,git没有保存它。你显然可以从fflbranche分支推送到远程。

$ git checkout fflbranche
// do changes & commit

$ git push -u origin fflbranche       
# -u = --set-upstream tells git to remember the parameters, so that next time you can simply run 'git push'

$ git remote show origin

答案 1 :(得分:0)

Git分支很懒,git不会创建本地分支,除非你命令它这样做。

通常情况下,git checkout会初始化具有远程状态的分支,并正确设置跟踪状态。

如果你想推动一个分支没有被跟踪(这通常是新分支),设置原点也有效:

git push --set-upstream origin "$(git-branch-current 2> /dev/null)"

您有多个可推送的遥控器,因此您还希望将origin替换为您想要的遥控器。