Getting Started with Git

Christian Carter
4 min readApr 28, 2021
Git Logo

Getting Git setup and learning the basics is key to making sure you never have that dreaded moment when your computer dies and you don’t have a backup of that project you have been working on for months. Git also allows you to improve your ability to work with teams on the same project without writing over the work anyone else has done. Here are some instructions on how to get started with Git.

First, you need to make sure that you have your GitHub account created and you have downloaded Git Bash. Now start your new repository. You will need to choose a name for it. A helpful tip while creating your repository is to add a “.gitignore” file. You can select the checkbox and search for the template for the type of project you are creating.

Once you have everything setup you can click to create the repository.

Next you want to clone the repository. To do this you need to copy the address of the repository you just created. This can be found under the “code” dropdown menu like in the image below.

Copy the address in the box. Now open the folder for your project. Right click and select “Git Bash here” which will open Git Bash for you. You are now going to connect it to your repository. To do this enter the following commands:

“git init” — This will initialize git in the folder.

“git remote add origin (Paste Repository Address Here)“ —After origin you need to paste the address of your repository. This can be done by clicking the wheel on your mouse (middle clicking). You could also right click and select paste. Here is an example:

To verify that it is connected enter: “git remote -v”. You may be asked to login to GitHub at some point. Now you are connected to your remote repository.

The are three main steps to always make sure you are working with the latest project from the repository and are publishing your latest work from your local computer.

First, you need to pull the latest from the repository. You can do that with the following command.

“git pull origin master”

Next, you need to commit your work. This is done in two steps using “add” and “commit”. When you do the commit you can add a message to let everyone know what you have changed in this commit.

“git add .” — Don’t forget the period at the end of the command. This adds all of the files from the project that were not already added.

“git commit -m “Message”” — Enter your message inside quotation marks.

Last, you will push everything from your local computer up to the repository. You can do that with the following command.

“git push origin master”

It’s possible in your first pull request you may get this response:

If you go back to github you can see if in the creation of your repo it may have named your branch something other than “master” most likely “main” like in the image below:

If you click on branch it will take you to a page where you can click on the edit pencil on the right to change the name of the branch to “master”. Now you can finish connecting your repository.

That is enough to get you started. As you do more you will want to learn about branches.

-Chris

--

--