GIT - Difference between tracking a branch versus cloning

后端 未结 3 886
傲寒
傲寒 2021-01-04 11:07

I\'ve seen this command floating around on various sites.

git checkout --track -b <...>

If I create a bare repo on a remote server and wor

3条回答
  •  星月不相逢
    2021-01-04 11:51

    When you use

    git checkout --track -b local_branch_name origin/remote_branch_name
    

    (usually with 'local_branch_name' the same as 'remote_branch_name', for which shortcut exists:
    "git checkout -b --track origin/branch_name"), it means that you create local branch named 'local_branch_name', on which you can create commits, for which the upstream branch would be remote-tracking branch named 'remote_branch_name' (which tracks/follows this remote-tracking branch).

    You need to remember that you can't commit directly on 'origin/remote_branch_name'; this remote-tracking branch is meant to track progress of 'remote_branch_name' branch in remote 'origin' ('origin' is default name of remote you cloned from).

提交回复
热议问题