Installing Git and Syncing with GitHub

Installing Git and Syncing with GitHub

Whether collaborating on a group project or working on your own projects, Git can be a powerful tool to save and share your code. Although incorporating Git can come at any point in your coding journey, many developers recommend starting a new project with Git. Once you have Git installed, you'll be able to start showing off your projects to otherer developers and potential employers on GitHub.

To get started, you'll need to:

  1. Install Git and use the default installation instructions

  2. Create an account on GitHub

Although there are several methods to start your first project using Git, creating your repository, or repo, on GitHub first may be the best option.

Benefits from starting your repo on GitHub:

1) Step-by-step walkthrough provided by GitHub

2) Fewer chances of error on both project initialization and sync to GitHub

Once you create a GitHub account, you can create your first repo by clicking on the New button at github.com.

Ignore repository template and name the repository. This will also be the name of the repository folder when added to your computer. You can choose to set the repository as Private, but if you want to share your project with others, you'll want to set the repository to Public.

Adding a README file can be beneficial to others viewing your project. A README file is a markdown file that will explain your project and provide instructions to users to view or edit the repo. You can add or remove a README file from your project at any time. When finished, click Create Repository.

You have now created your first repository! However, it's only in GitHub right now, and we need it synced to your computer. To do this, we'll clone the GitHub repository to your computer. Click the Code button and copy the URL provided in the HTTPS tab.

Choose a folder on your computer where you want to store this repo. Typically, a developer will create a folder in their Documents folder or Desktop called "repo" or "git". In this example, I'm going to create a folder in my Documents folder called "git".

After you create your folder, open Git Bash. You will need to change directory (cd) to your new folder.

cd Documents/git

If you get an error, check your spelling and make sure your new folder is located where you expect. Below is what you should expect to see if you changed your directory successfully.

Next, clone the repo using your copied URL.

git clone https://github.com/mikesheehy/MyFirstProject.git

Now you have your repository in both GitHub and on your computer, but how do I update my project? Will I have to make changes in both places? In the next post, I'll walk through updating the new Git repo.