|
| 1 | +--- |
| 2 | +id: Git Clone |
| 3 | +sidebar_position: 5 |
| 4 | +--- |
| 5 | +import Tabs from '@theme/Tabs'; |
| 6 | +import TabItem from '@theme/TabItem'; |
| 7 | + |
| 8 | +Instead of starting a new project from scratch, you can use Git to clone an existing repository — copying all its files, branches, and history to your local machine. |
| 9 | + |
| 10 | +This is one of the most common ways to start working on a project that’s hosted on GitHub or another remote platform. |
| 11 | + |
| 12 | +## What does `Git clone` do |
| 13 | + |
| 14 | +Actions of the git clone command are as follows: |
| 15 | + |
| 16 | +* Creates a local copy of a remote repository. |
| 17 | + |
| 18 | +* Automatically sets up the connection to the remote (`origin`). |
| 19 | + |
| 20 | +* Downloads all branches and commit history. |
| 21 | + |
| 22 | +**Example** |
| 23 | + |
| 24 | +```bash |
| 25 | +git clone <repository-url> |
| 26 | +``` |
| 27 | + |
| 28 | +## Clone Your First Repository |
| 29 | + |
| 30 | +1. Open a terminal or command prompt. |
| 31 | + |
| 32 | +2. Navigate to the folder where you want to download the repo: |
| 33 | +```bash |
| 34 | +cd projects # or any other directory |
| 35 | +``` |
| 36 | +3. Run the clone command: |
| 37 | +```bash |
| 38 | +git clone https://github.com/Tom-Fynes/git-101 |
| 39 | +``` |
| 40 | + |
| 41 | +4. You should see output like: |
| 42 | +``` vbnet |
| 43 | +Cloning into 'git-101'... |
| 44 | +remote: Enumerating objects: ... |
| 45 | +remote: Counting objects: ... |
| 46 | +Receiving objects: ... |
| 47 | +Resolving deltas: ... |
| 48 | +``` |
| 49 | + |
| 50 | +5. Now check your files: |
| 51 | + * Change directory to newly cloned repo |
| 52 | +```bash |
| 53 | +cd git-101 |
| 54 | +``` |
| 55 | + |
| 56 | + * List all files and folders in directoy |
| 57 | + |
| 58 | +<Tabs> |
| 59 | + <TabItem value="Windows" label="windows" default> |
| 60 | + ```bash |
| 61 | + dir |
| 62 | + ``` |
| 63 | + </TabItem> |
| 64 | + <TabItem value="MacOs" label="Mac"> |
| 65 | + ```bash |
| 66 | + ls |
| 67 | + ``` |
| 68 | + </TabItem> |
| 69 | + <TabItem value="Linux" label="linux"> |
| 70 | + ```bash |
| 71 | + ls |
| 72 | + ``` |
| 73 | + </TabItem> |
| 74 | +</Tabs> |
0 commit comments