GitHub Repository First-Time-Setup
For Beginners
At the heart of GitHub is an open source version control system (VCS) called Git. Git is responsible for everything GitHub-related that happens locally on your computer.
Setting up Git
Download and install the latest version of Git over here https://git-scm.com/downloads .
Setup your username in Git
Git uses a username to associate commits with an identity. The Git username is not the same as your GitHub username.
- Open Terminal.
- Set a Git username:
$ git config --global user.name "Lionel Messi"
3. Confirm that you have set the Git username correctly:
$ git config --global user.name
> Lionel Messi
Setting your commit email address in Git
- Open Terminal.
- Set an email address in Git.
$ git config --global user.email "email@example.com"
3. Confirm that you have set the email address correctly in Git:
$ git config --global user.email
email@example.com
4. Add the email address to your account on GitHub, so that your commits are attributed to you and appear in your contributions graph.
Setting your commit email address on GitHub
GitHub uses your commit email address to associate commits with your GitHub account.
- In the upper-right corner of any page, click your profile photo, then click Settings.
- In the left sidebar, click Emails.
- In “Add email address”, type your email address and click Add.
- Verify your email address. Verifying your primary email address ensures strengthened security, allows GitHub staff to better assist you if you forget your password, and gives you access to more features on GitHub.
- In the “Primary email address” list, select the email address you’d like to associate with your web-based Git operations.
- To keep your email address private when performing web-based Git operations, click Keep my email address private.
Create a Repository
To put your project up on GitHub, you’ll first need to create a repository for it to live in. Your repository is like a folder where all your project are kept and updates to those projects are saved.
- In the upper-right corner of any page of your GitHub Account, use the (+) symbol for the drop-down menu, and select New repository.
- Type a short, memorable name for your repository. For example, “hello-world”.
- You can also add a description of your repository. For example, “My first repository on GitHub.” However this is optional, so you don’t need to spend much time thinking over what to write.
- Choose a repository visibility. In our case we shall be using “Public”. This means that anyone can see your repository and you can choose who gets to make commits. Public repositories are accessible to everyone on the internet. Private repositories are only accessible to you, people you explicitly share access with, and, for organization repositories, certain organization members. Internal repositories are accessible to enterprise members.
- Next you select: Initialize this repository with a README. A README communicates important information about your project, expectations for your project and helps you manage contributions. A README is often the first item a visitor will see when visiting your repository. README files typically include information on:
- What the project does
- Why the project is useful
- How users can get started with the project
- Where users can get help with your project
- Who maintains and contributes to the project
6. Finally you click Create repository.
Wow! You have successfully created your first repository!
Cloning a repository from GitHub
When you create a repository on GitHub, it exists as a remote repository. You can clone your repository to create a local copy on your computer and sync between the two locations.
Cloning a repository pulls down a full copy of all the repository data that GitHub has at that point in time, including all versions of every file and folder for the project.
Cloning a repository using the command line or terminal
- On GitHub, navigate to the main page of the repository.
- Above the list of files, click the download symbol next to Code.
- To clone the repository using HTTPS, under “Clone with HTTPS”, click the clipboard symbol to make a copy of the your code. We shall not be using the SSH option as it requires you to have created an SSH Key. If you don’t already have an SSH key, you must generate a new SSH key. If you’re unsure whether you already have an SSH key, check for existing keys.
- Open the Terminal or Command Line on your computer.
- Once you have opened the terminal, change your current working directory to the location where you want the cloned directory. You can do this by typing:
cd target
Where cd is change directory and target is the folder you want to enter.
6. Type git clone
, and then paste the URL you copied earlier.
$ git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY
7. Press Enter to create your local clone.
$ git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY
> Cloning into `Spoon-Knife`...
> remote: Counting objects: 10, done.
> remote: Compressing objects: 100% (8/8), done.
> remove: Total 10 (delta 1), reused 10 (delta 1)
> Unpacking objects: 100% (10/10), done.
Conclusion
This may seem like an overwhelming amount of steps to follow, but I promise that the more you stick with this process the clearer it all becomes.
I hope this article has been helpful, if there are any further questions on the topic here are some links to great resources that have helped me in my web development journey:
1. Getting started
Learn how to start building, shipping, and maintaining software with GitHub. Explore our products, sign up for an account, and connect with the world’s largest development community.
2. Git Tutorials and Training | Atlassian Git Tutorial
Learn the basics of Git through this comprehensive Git training. Branching, pull requests, merging and more are covered in the Atlassian Git tutorial.