Skip to main content

Command Palette

Search for a command to run...

Demistifying Git and GitHub: A Beginner's Guide to Version Control and Code Collaboration

Updated
4 min read
Demistifying Git and GitHub: A Beginner's Guide to Version Control and Code Collaboration
I

Software Developer with interest in building scalable, maintainable and high end quality applications as well as documenting the developers experience.

Exploring the software development world can be daunting for beginners, exploring tools can be overwhelming and sometimes leaves you confused. Do not worry, whether its your first time of hearing this terms or you"re not too familiar with what there are, in this article we will delve into the essentials of what git and github are, and how there will enhance your development experience.

In this article we will explore the following:

  • Why you need Git and Github?

  • What is Git?

  • What is Github?

  • Download and Install Git

  • Make your first git Commit

Why you need Git and Github:

You might have written your first line code or an amazing program and it is nestled securely on your computer, the question arises: How do you share this code with fellow developers? The conventional approach might be through a flash drive, but consider the vulnerability—what if an unfortunate incident befalls your hard disk, putting everything, including your flash drive, at risk?. "Hey you might have just lost everything"!.

Now that is where Git and GitHub Comes In

What is Git?

Git is a distributed version control system that allows multiple developers to collaborate on a project. This means its keeps history of changes made to a project's source code, allowing developers to review, revert, and compare changes over time. Each developer has a complete copy of the project's repository, including its entire history. This allows developers to work offline and collaborate seamlessly. With various versions of your source code saved in different timeline on your computer, how then do you share this code or work, since this tracking is still on your local machine?

Now Github comes in

What is Github?

GitHub is a web-based platform that provides hosting for software development and version control systems like git. GitHub hosts Git repositories, allowing developers to track changes in their source code, collaborate with others, and manage different versions of their projects.

Now you know what this terms basically mean, enough of the talking, lets get to work

To use git you must first download git from .https://git-scm.com/downloads ensure you select the appropriate version for your operating system.

Verify if Git is installed by using the following command in the command prompt:

git --version

Now git is installed

Github is web based and as such you have to create an account, head over to https://github.com/signup to create an account. Follow the instructions and you"ll have your account ready in no time.

Congratulations. You"ve installed git in your local machine and you"ve created your github account.

It's time to make your first commit and push to github

A commit in git basically represents a snapshot of the project at a specific point in time.

  1. In your computer, create a folder for your project. Let’s call the project folder github-tutorial..

  2. Go into into the folder, create an empty index.html file.

  3. Open a terminal or command prompt and navigate to your project's root directory using the cd command.

    it should look like this

  4. Initialize a local git repository, using the command git init

  5. Edit your index.html file to include a content

  6. Add Commit and Changes Locally git add . git commit -m "initial commit"

  7. Create a GitHub Repository:

    • Go to GitHub.

    • Log in to your account

    • Click the "+" in the top right corner and select "New repository."

    • Fill in the repository name, add a description (optional), and click "Create repository."

  8. Add Github Repository as Remote git remote add origin https://github.com/your-username/your-repo.get

  9. Push Code to GitHub:

    git push -u origin master

    Congratulations! You've successfully initialized a local Git repository, created an index.html file, committed changes, created a GitHub repository, added it as a remote, and pushed your code to GitHub.

Conclusion

Git and Github are essential tools for developers and as such mastery of this tools would be beneficial to you, easing your developer journey and ensuring collaboration.