GIT - Difference between tracking a branch versus cloning

后端 未结 3 918
傲寒
傲寒 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 12:07

    The command above will not work if you're not in a repository. To work with git, you must always first create a repository, either by cloning one which already exists or using git-init and starting from scratch.

    git checkout --track -b  
    git checkout --track 
    

    These two commands create a new local branch to track . The first one manually names it ; the second uses the same name as the remote.

    Remember that tracking doesn't mean automatic update - it simply does things like specifying where the branch should push/pull from and letting git status give those "your branch is behind origin/master by 5 commits, and can be fast-forwarded" messages.

提交回复
热议问题