简体   繁体   中英

About Git clone and branch

My understanding is that Git clone bring everything from remote locally. Now, when I want to work on a branch that is part of repository, why do I have to create a local branch because the branch already exists and as I have cloned it, it should exist in the local clone also

well.. you are right, git clone (...) get in you local machine the repo.

git branch (..) create a local branch.

Now if the branch you want to use is already in the repo that you just cloned, you dont need to re create the branch (you can, but its not necesary). you can just use git checkout without a previous git branch (..)

Example: repo got 2 branches. master and dev *git clone (url bla bla)

*cd /repoName (now you are in master branch)

*git branch -a (this will show you all branches, red are remotes, white local, and green actual branch)

*git checkout dev

And thats all, you go to dev branch, and you didnt created it. (only for already existing remote branch)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM