Cloning a repository


To work on the contents of an existing Git repository, the first step will often be to “clone” it to your local working environment (i.e. your laptop!).

Getting the clone URL

To clone a repo, you’ll first need to find the necessary URL.

  • Go to the git-academy-sandbox repository page on GitHub.

  • Click the “Code” button and copy the URL (HTTPS link).

Open the Git Bash terminal and create a folder to store your repos if you haven’t already:

cd ~/
mkdir repos
cd repos

Now clone the repository using the following command (which includes the repository URL you should have copied using the steps earlier in this page) and then change directory (cd) into the folder that creates:

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

After following the above steps, you should now see the current branch name (e.g. main) at the end of the file path as below:

Tip
  • Enter ls to list what files and folders are present in the repo folder.
  • Type git log to view recent commits. Press q when you are ready to exit the Git log.
  • Type git status 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).
  • 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”.

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.

  • In PyCharm, go to File > Project from Version Control.

A screenshot showing the PyCharm interface with the File menu open and the Project from Version Control option highlighted.

  • Paste the URL you copied from GitHub into the “URL” field and choose a directory on your device where you want to save the repo.

    • If you change the directory, you need to ensure to create a folder with the same name as the repository as it will not be automatically done for you.
  • Click “Clone”.

A screenshot showing the PyCharm interface with the URL field filled in and the Clone button highlighted.

Back to top