Cloning into a new directory

CHEATSHEET:

HOW TO CLONE, FETCH, and PULL

In the command line 'git clone' will copy a repo into a newly created directory, and creates remote-tracking branches for each branch in the cloned repository.

This command additionally creates a remote called 'origin' for the repo cloned from, and sets up a local branch based on the remote's active branch (usually master). It also creates remote-tracking branches for all the branches in the repository.

$ cd /newfolder
$ git clone git@github.com:username/Project-Name.git
$ git branch
* master
remoteBranch

A current local repo with a remote set up for the current project, you can git fetch. Git fetch is similar to pull, but it will not do any merging.

Fetch does not make any changes to local branches, so you will need to merge a remote branch with a paired local branch to incorporate new fetch changes.

$ git fetch

Git Pull will pull down from a remote and instantly merge into the branch you're in when you make the request. Pull is a high-level request, that runs 'fetch' and 'merge' by default.

Similar to git fetch, you can use git to fetch a specific branch and merge it into your current local branch. For one-time pull from other user's repos, you can use a URL in place of a remote name.

$ git pull origin master