How to create a local branch from an existing remote branch?

后端 未结 5 2004
半阙折子戏
半阙折子戏 2021-01-31 08:42

I want to create a branch from an existing remote branch (let\'s say remote-A) and then commit the changes to the repository.

I have used the below commands to create a

5条回答
  •  -上瘾入骨i
    2021-01-31 09:08

    I wanted to create a new local tracking branch from a remote git branch with a different name.

    So I used this command:

    git checkout -b --track /

    Example:

    git checkout -b local-A --track origin/remote-A

    I saw it in multiple comments to the above answers, but it's good to have it in the first sight.

    Tracking branches are local branches that have a direct relationship to a remote branch. If you're on a tracking branch and type git pull, Git automatically knows which server to fetch from and which branch to merge in.

提交回复
热议问题