Skip to content

Commit

Permalink
Adding in cloning instructions and standardising filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
rmbielby committed Nov 21, 2024
1 parent 855c05e commit 37b7aee
Show file tree
Hide file tree
Showing 20 changed files with 77 additions and 133 deletions.
56 changes: 0 additions & 56 deletions ch2-git-basics/basic-workflow.qmd

This file was deleted.

77 changes: 0 additions & 77 deletions ch2-git-basics/cloning.qmd

This file was deleted.

Empty file removed ch2-git-basics/syncing.qmd
Empty file.
Empty file.
Empty file.
Empty file removed ch5-navigating/the-head.qmd
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
77 changes: 77 additions & 0 deletions git-refresher/clone-a-repo.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
title: "Cloning an Existing Repository"
---

---
## Introduction

This section will guide you through the process of cloning a GitHub repository (repo). A repo contains all of your code, your files and each file's version history. Repos can have multiple collaborators and can be either private or public. You can find out more about GitHub repos on [GitHub Docs](https://docs.github.com/en/repositories/creating-and-managing-repositories/about-repositories).

If you have a repo on Azure DevOps, GitHub or GitLab, you generally can't edit or run your work on those platforms, so if you need to work with the contents of a repo, you'll usually need to make a clone.

There are several ways to clone an existing repo. Below, you'll find two methods. The first uses Rstudio and the second uses Git Bash. Start with step 1, which is the same for both methods, and then decide which method to follow. Once you have successfully cloned, you should see the files appear in the location you have chosen to store your repo.

## Step 1: Get the repository clone link

a\. Go to the [git-academy-sandbox](https://github.com/dfe-analytical-services/git-academy-sandbox) repository page on GitHub.

b\. Click the "Code" button and copy the URL (HTTPS link).

::: panel-tabset
## To Clone Using Git Bash:

### Step 2a: Open folder and Git Bash

Navigate to the folder on your device where you want to clone the repo. Right-click in the directory and select "Git Bash Here".

![](images/clone_gitbash-here.png){width="343"}

### Step 2b: Clone the Repository in Git Bash

- In the Git Bash window that opens, use the \`git clone\` command followed by the URL you copied from GitHub. For this repo, we would enter:

``` bash
git clone https://github.com/dfe-analytical-services/git-academy-sandbox.git
```

You will need to right-click to paste, as the keyboard shortcut will not work in Git Bash and then press enter.

### Step 2c: Verify the clone in Git Bash

- Navigate into the repo by typing **cd git-academy-sandbox** and pressing enter.

- You should now see the current branch name (e.g. main) at the end of the file path as below:

![](images/clone_gitbash-nav.png){fig-align="center"}

- Type **git log** and press enter to view recent commits. Press **q** when you are ready to exit git log.
- Type **git status** and press enter to check the state of the cloned repository (at this point, it should say everything is up to date, as you haven't made any changes yet).

## Or, to Clone Using RStudio:

### Step 2a: Open RStudio

Open RStudio on your device.

### Step 2b: Clone the Repository in RStudio

- In RStudio, go to **File \> New Project \> Version Control \> Git**.

- Paste the URL you copied from GitHub into the "Repository URL" field.

- Choose a directory on your device where you want to save the repo.

- Click "Create Project".

![](images/clone_rstudio-here.png){width="467"}

### Step 2c: Verify the Clone

Check the Files pane in RStudio to see if the repo files have been cloned to your local machine. The files pane normally opens in the right-hand bottom corner of RStudio.

![](images/clone_rstudio-files.png)
:::

## Conclusion

You have successfully cloned a GitHub repository! Continue on to learn how to create branches.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes

0 comments on commit 37b7aee

Please sign in to comment.