Tech Notes

Git & GitHub for Beginners

GitHub Basics

Github basics, including how to create an account and how start a repository.

GitHub is a server that allows you to store your changes in remote repositories. This is a wonderful tool, as you have access to your work from any computer that is hooked to the internet AND you can collaborate with others very easily while working on code.

GitHub is free to use, simply go to:

github.com

and sign up for a free account. Once you are signed up follow these steps:

  1. Navigate to your account page
  2. Click on the Repositories tab.
  3. Click on 'NEW' button to creat a repository.
  4. Do Not initialize with a README file for this repository.

Now that you have created your remote repository, open your command line, navigate to your projects directory, and type in the following commands:

git remote add origin url-of-repository

To find the URL of your repository, simply navigate to that repo's page on GitHub. Then you can copy the address by clicking on the 'clone' button. You can also copy the address from the adress bar on your web browser while on the repo's page.

Now your local repository is connected to your remote repository. Next we will push our changes to GitHub.

back to top

How to push your changes to an online repository, namely Github.

Next we are going to push our changes to GitHub, saving them in our remote repository that we just created. The first time you push a commit you will type in this command:

git push origin main

The above is for the first time push on any new repository. Once you have pushed commits to your remote repo for the first time the rest of your pushes are done using:

git push

Now your files, and all of the changes made are saved to Github where you can work on them, share them and allow collaboration, just to name a few things. Once you have this set up, it is very quick and simple to keep everything up to date and in synch. To Summarize:

git add filename

git commit filename -m "message about changes"

git push

That's all for basic use of Git and GitHub, there is a lot more you can do with these amazing tools. Don't be intimidated, you will get the hang of it. The following sections are just extra tidbits I am still learning, you might find them useful.

back to top