Information Technology Reference
In-Depth Information
4. Create a local master branch that will point to the same revision as the
origin/master remote tracking branch: $ git rev-parse
origin/master > .git/refs/heads/master
5. Set up the master branch as a local tracking branch for the remote
tracking branch origin/master with: $ git branch --set-
upstream-to=origin/master
6. Store the information about the default branch in the remote repository
locally: $ git symbolic-ref refs/remotes/origin/HEAD
refs/remotes/origin/master
7. Checkout the files in the working directory: $ git checkout
How It Works
This recipe demystifies the cloning operation. It splits cloning into:
• Initialization
• Definition of a remote
• Downloading the git database and remote tracking branches
• Creating appropriate branches
Git starts a clone, initializing a new empty repository with the $ git init com-
mand. Right after this command the repository is empty—it doesn't contain any
branches. The output of $ git branch is empty.
To copy the revisions from an external source we need an URL. This URL is set
with the $ remote add [alias] [URL] command. The first parameter is the
short alias; the second parameter is an URL. Once you define a remote origin with:
$ git remote add origin https://github.com/creationix/
jz-git.git
you can use a short alias origin instead of full URL. The command:
$ git fetch --no-tags origin master:refs/remotes/origin/
master
Search WWH ::




Custom Search