简体   繁体   中英

how to clone origin master as a new local branch?

I have a local master modified something.I want to clone origin master as a new local branch.I tried some way as below.But I found there are some different ways between master and the new branch.I don't know why this happend.And how can I clone origin master as a new local branch totally same.

  1. git fetch origin master:newMaster
  2. git checkout -b newMaster origin:master
  1. git fetch origin
  2. git checkout -b newMaster origin/master

origin is the name of the remote repository you clone from. origin/master is what is known as a "remote tracking branch". It is how your local repository tracks the master branch on the origin repository.

git fetch origin updates your view of the remote repository by pulling down new commits and updating your remote tracking branches (ie. origin/master ). Then you can simply make a branch off origin/master like any other branch.

See Working with Remotes in the Git Book for more.

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