In this section, we’ll guide you through the process of Creating, Forking, and Cloning Repositories. Some of these terms you might not understand just yet - that’s okay. By the end of this section, it will be much more clear.
To put it simply, a Repository, often shortened to “Repo,” is a location in which your code managed by git is stored. When you tell Git to manage a specific folder, that folder becomes a Repository of the information held within it. Every change that you save to Git is stored locally, tracked, and easily-accessible to you at any time. But before we can make use of these benefits, we need to tell Git that we want to track our folder. So let’s get started:
What we want to do right now is to create a folder, and then have it’s contents be tracked by Git. So let’s get started!
Documents
folderGit Guide
.Initializing a Git Repo
Git Bash here
Open in Terminal
git init
You should see the following message:
Initialized empty Git repository in FILEPATH HERE
If you have the OS option to show hidden files enabled, you will also see that there’s a new .git
folder in your folder
Congratulations, you’ve created your first Git Repository! It’s a little bit empty right now, but soon we’ll show you how to make use of it. First, let’s look at another option: Cloning a Repo.
We’ve already created our own local repository, but what if we want to work with an existing Repo instead? This is where Github comes in. Follow this link. It’ll take you to the Community Library team’s Sample Mod Template.
If you’d like to take a moment to get familiar with the GitHub UI, click this button:
Now that we understand how to initialize a Repo, let’s take a look at cloning a repo from GitHub. First, let’s make sure we have git open:
Code
button, and copy the URL-like line in the middle of the dropdown.git clone
, followed by a space, and then the link you just copied, then hit Enter. It will look something like this:git clone [email protected]:BG3-Community-Library-Team/BG3-Community-Library.git
The console will display some progress text, and you should have a new folder, “Sample-Template.” Now, let’s use the console to bring Git into the folder:
cd Sample-Template
, and hit EnterYou’ll now see the that you’re in a repo. Input get branch
to see what branch you’re on - it should respond with * main
.
By this point, we understand the difference between Git and GitHub. We’ve learned what Version Control is, and how Git’s focus is to take and store snapshots of a codebase. We’ve familiarized ourselves with the GitHub UI, installed Git, learned how to create a Repository from Scratch, and learned how to clone down an existing Repository. Next, we’ll cover topics relating to Branches: What a branch is, how to create a snapshot of your code, and switch away to a different Branch. How to upload and download from GitHub using Version Control.