Reputation: 695
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.
git fetch origin master:newMaster
git checkout -b newMaster origin:master
Upvotes: 0
Views: 838
Reputation: 165536
git fetch origin
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.
Upvotes: 4