GitHub Basics 101 🍻

Kamalveer Singh
4 min readSep 15, 2024

--

If you’ve ever thought about putting your code online or you want to learn Version Control System (VCS) for your pushing your projects GitHub is an ideal place to get started.

In this blog you’ll get to know about the GitHub basics —

  1. Setup
  2. Creating a Repository
  3. Connecting the repo to your system
  4. Adding your code to Git
  5. Committing changes
  6. Pushing code to GitHub

Setup

To setup a GitHub account visit — https://github.com/signup. If you already have an account, simply sign in. Once you have your account ready proceed to the next steps.

Creating a repository

A repository (or repo) is like a folder/directory on your system, it’s a folder present in your account which contains the code and files you put there.

Click on `New repository`

To create a repo —

  1. Click on the “+” icon in the upper right corner of the GitHub homepage.
  2. Select “New repository”.
  3. Fill in the repository name, description, and choose whether it should be public or private.
  4. Click “Create repository”.
Fill in the repository details

Now that we have created a repo the next step is to connect it to your system and push your project to the repo.

Connecting the repo locally

To connect your repository locally you need to open your terminal / command prompt and navigate to the directory where you want to clone your repo.

git clone https://github.com/yourusername/your-repo-name.git
Example for Cloning a Repo

Replace yourusername with your actual username and your-repo-name with the name of your repository.

Now if you use dir command, you’ll see a folder having the same name as your repo, use cd your-repo-name to direct yourself there.

Change your directory to your repo

Adding your code to the repo

If you are starting a new project, then code it in that folder itself and if you have already made a project then move its files to the repo.

Then use the git status command to see the status of your files.

example of git status command

To add all the changes which you have made to your repo use the git add . command. You can again use git status to see what’s changed.

Adding files using git add

Committing Changes

When you are ready to push your code to the GitHub repo use the following command to commit it first.

git commit -m "add my project version 1.1"

The -m option provides your commit with a message which provides the information about what you did in that commit.

If you want to make more changes to the project, then make those changes and use git add command add then use the git commit command to commit those changes with a relevant message.

example of git commit command

Pushing your code to the GitHub

Finally, to push your local project to the destined GitHub repo use the following command —

git push origin main
example of git push

This will upload all of your commits to the GitHub repo.

You can check your project at — https://github.com/your-user-name/your-repo-name/ and verfiy the changes.

NOTE: Only the files which you have committed will be shown in the repository and if you want to skip some files like logs or irrelevant files then you can use .gitignore file.

Commands covered —

git clone https://github.com/yourusername/your-repo-name.git

git add .

git add index.html

git commit -m "add index.html file"

git push origin main

I hope this blog helped you to learn the essential commands to getting started with GitHub. There is more to GitHub like — branches, merging, conflicts, pulling etc. but these are the essentials which everyone should know.

If you have any problems with it feel free to ask in the comments : )

Thankyou : )

--

--

Kamalveer Singh
Kamalveer Singh

Written by Kamalveer Singh

0 Followers

I love Computer Science <3

Responses (1)