<!-- Please follow this checklist and put an x in each of the boxes, like this: [x]. It will ensure that our team takes your pull request seriously. --> - [x] I have read [freeCodeCamp's contribution guidelines](https://github.com/freeCodeCamp/freeCodeCamp/blob/master/CONTRIBUTING.md). - [x] My pull request has a descriptive title (not a vague title like `Update index.md`) - [x] My pull request targets the `master` branch of freeCodeCamp.
		
			
				
	
	
		
			62 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
			
		
		
	
	
			62 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
| ---
 | |
| title: Git Clone
 | |
| ---
 | |
| ## Git Clone
 | |
| 
 | |
| The `git clone` command allows you to copy a remote repository onto your local machine.
 | |
| 
 | |
| First, find the remote repository for the project you're working on or interested in - this can also be your fork of a project. Next, copy the URL for it. For example, if you've forked the freeCodeCamp guides repository, the URL looks like `https://github.com/YOUR-GITHUB-USERNAME/guides.git`.
 | |
| 
 | |
| In the command line on your local machine, navigate to where you want to save the project in your working directory. Finally, run the `git clone` command:
 | |
| 
 | |
| ```shell
 | |
| git clone URL-OF-REPOSITORY
 | |
| ```
 | |
| 
 | |
| The default name of the new directory on your computer is the name of the repository, but you can change this by including the last (optional) parameter:
 | |
| 
 | |
| ```shell
 | |
| git clone URL-OF-REPOSITORY NAME-OF-DIRECTORY-ON-COMPUTER
 | |
| ```
 | |
| 
 | |
| Git gives the remote the alias "origin". This is a useful way to refer to the remote when you want to push your changes to the remote server or pull changes from it. See <a href='https://guide.freecodecamp.org/git/git-push/' target='_blank' rel='nofollow'>Git push</a> and <a href='https://guide.freecodecamp.org/git/git-pull/' target='_blank' rel='nofollow'>Git pull</a> for more details.
 | |
| 
 | |
| Git only pulls the remote's main branch onto your computer. This branch is usually named "master" by convention but may be defined differently depending on the project.
 | |
| 
 | |
| Also, Git automatically sets up your local main branch to track the remote branch. When you run `git status`, you'll see information about whether your local branch is up-to-date with the remote. Here's an example output:
 | |
| 
 | |
| ```shell
 | |
| myCommandPrompt (master) >> git status
 | |
| On branch master
 | |
| Your branch is up-to-date with 'origin/master'.
 | |
| nothing to commit, working tree clean
 | |
| myCommandPrompt (master) >>
 | |
| ```
 | |
| 
 | |
| If your local `master` branch has three commits that you haven't pushed up to the remote server yet, the status would say "Your branch is ahead of 'origin/master' by 3 commits."
 | |
| 
 | |
| ### Git Clone Mirror
 | |
| 
 | |
| If you want to host mirror of a repository you can use mirror parameter. 
 | |
| 
 | |
| ```shell
 | |
| git clone URL-OF-REPOSITORY --mirror
 | |
| ```
 | |
| 
 | |
| After mirroring a repository, you can clone your local mirror from your server.
 | |
| 
 | |
| ```shell
 | |
| git clone NAME-OF-DIRECTORY-ON-COMPUTER
 | |
| ```
 | |
| 
 | |
| ### To clone a spacific branch
 | |
| 
 | |
| If you want to clone a spacific branch, you can do that by the following command.
 | |
| 
 | |
| ```shell
 | |
| git clone URL-OF-REPOSITORY -R branch_name
 | |
| ```
 | |
| 
 | |
| ### More Information:
 | |
| - Git documentation: [clone](https://git-scm.com/docs/git-clone)
 |