zyMacro
zyMacro

Reputation: 695

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

Upvotes: 0

Views: 838

Answers (1)

Schwern
Schwern

Reputation: 165536

  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.

Upvotes: 4

Related Questions