back to top

How to Get Started with GitHub

Getting started with GitHub repositories!

GitHub is a web-based platform that uses Git for version control. It is predominantly used for computer code but can be used to manage any other types of files. It provides a distributed version control system for tracking changes in any set of files, as well as several collaboration features, such as bug tracking, task management, and wikis for every project.

This tutorial is intended to be a quick and simple way to using GitHub at the most minimal level but covering all of the features you would need to take advantage of using it as a repository for your files, projects, and applications. This guide will take you through creating a repository on GitHub, and the following commands: Git clone, Git add, Git commit, and Git push.

  1. Downloading the Git BASH console
  2. Creating a GitHub Repository
  3. Cloning your Repository
  4. Modifying your Repository
  5. Verifying your Changes

Downloading the Git BASH console:

This is the tool that we’ll be using for our Git commands. Git BASH is included with Git for Windows, which also comes with a few other utilities such as Git GUI and Git Credential Manager, you’ll find all of these to be useful but for this we’ll mostly just be using the Git BASH console. You can accept all default settings during the setup.

Download – Git for Windows – https://gitforwindows.org/

Creating a GitHub Repository:

Now let’s begin with GitHub through your internet browser. Create an account if you haven’t already, and then go to your Repositories page. You’ll have an option there as a green button that says “New”, go ahead and click it to begin the process. You’ll be presented with a few options:

Repository name: This will be your project name as well as your url to it, it’s best practice to use lowercase and hyphens. Numbering is not necessary unless you already have a repository with that name or you just want to include it.

Description: This describes your repository, it’s optional and can be added later. If you add it at this time it will be copied into your README.md file, and tied to the history of that file. I just keep it empty when creating a new repository.

README file: This file is where you can set a long description including all sorts of notes such as details about the project, instructions to hosting it, references, and more. It also supports HTML with Markdown, you can link to both internal and external images with it as well.

GitIgnore file: This file instructs the repository to exclude specific files like secrets, configurations, or keys. It’s often tailored to the system or IDE used, such as VisualStudio. More optimized or custom GitIgnore files can be found online or manually configured.

License file: This file outlines legal terms for the repository, including use, modification, and distribution of the code. It applies to all contents unless superseded by another license in a subfolder. Open-source projects commonly use the permissive MIT License, but others may be chosen based on the owner’s requirements.

Cloning your Repository:

Now that you’ve created one, go to the page for it. You should see a green button that says “Code”. Click it and you’ll find the HTTPS code for your repository, go ahead and copy the url so we can clone it locally.

Now go to your console and navigate to the directory where you want to clone it to. You can navigate using BASH commands, or just right-click inside your directory and select “Git Bash Here”. Note, pasting in this console may be easiest for you with Shift + Insert as opposed to Ctrl + V.

Git Clone:

git clone REPOSITORYURLHERE

Note, you may be prompted to verify your GitHub credentials at this point before it allows the cloning. You should now see your project folder in that directory, including a .git hidden folder. This is for the Git configuration, don’t delete it. This represents a local repository that is a clone from what we created on GitHub. Changes here will later be reflected to your GitHub repository.

Modifying your GitHub Repository:

This includes just about any change you make to the repository. Let’s do a simple one. Open up the README.md file in a text-editor, such as Notepad. Under your header (which should be your repository name), let’s just add “Hello world!”. Save the document and then close out of Notepad. Now open your Git BASH console to the repository location, or navigate from your current console.

Now we’re ready to begin the process of sending our changes. First we start off with Git Add. This command adds a change from this directory to the staging area to let Git know that you want to update files.

Git Add:

git add .

Now we want capture a snapshot of the current changes that we have added to the staging area, we do this with the Git Commit command. This also allows you to also add a message for what the changes are doing.

Git Commit:

git commit -m "Update README.md"

Note, this is also the default commit message when updating the README.md file from GitHub. You can also be more specific about the changes such as:

git commit -m "Add hello message in README.md"

You can continue with making more commits to your staging area, but I think we’re ready to go ahead and push our current changes. So we’ll go ahead and make use of the Git Push command. This will put everything we’ve done locally on our machine onto the GitHub repository.

Git Push:

git push

Verifying your Changes:

Now let’s go back to our GitHub in the web browser and verify our changes:

As you can see from the commit in the header of our repository, it was pushed two minutes ago and has our commit message. You also see this on the file within the repository contents. Then we can actually see the changes at the bottom because a readme file is displayed by default when viewing a repository.

Conclusion:

In conclusion, we’ve successfully traversed the essentials of Git and GitHub: from creating a new repository to cloning it on your local machine, making alterations, and pushing these changes back to the remote repository. These core operations, along with the utilization of Git BASH, form the backbone of many software development and collaborative projects.

Working with the Git for Windows software and Git BASH console provides a unified and powerful platform for version control, offering a substantial advantage by ensuring that your work is safe, trackable, and reversible. However, remember that we’ve only skimmed the surface of what Git can do. There are numerous advanced commands and concepts, such as branching and merging, which were beyond the scope of this tutorial but are worth exploring to increase your proficiency with this tool.

Popular

More like this
Related

Pi-hole Setup Guide on Raspberry Pi

Introduction This comprehensive guide will take you step-by-step through the...

Thunderbolt 5: A Leap Forward in Connectivity

Intel has officially unveiled Thunderbolt 5, the next-generation connectivity...

Top 5 Browser Extensions You Need to Install Today

Enhancing your browser with the right extensions can make...

Year in Review: 2023 – Technology News

Reflecting on 2023, a pivotal year in technology, we...