How to 'git remote add' and track a branch in the same filesystem

后端 未结 2 2107
小蘑菇
小蘑菇 2021-02-18 18:18

I have 2 local git archives in /a and in /b which were cloned from remotes/origin.

There is a new branch z on /b

How can I track and fetch branch z from archive

2条回答
  •  面向向阳花
    2021-02-18 18:27

    I don't think you can do that.

    I think you'll need to push branch z to origin in b and fetch it from a.

    cd /b
    git push origin z
    

    That last command pushes local branch z to remote (so pushing z -> origin/z)

    then you can track it locally in repo a:

    cd /a
    git checkout -b z origin/z
    

    That last command creates (and checks out) a local branch z that tracks origin/z

提交回复
热议问题