Git and GitHub Tutorial for Beginners (Part 1)

Programming GIT AND GITHUB SERIES Image

    Introduction

    Git and GitHub are integral to the software development workflow of many large teams. They also power some of the most popular open-source projects. It’s essential that you get familiar with Git and make GitHub an integral part of your workflow as a developer.

    Today, we will provide a quick introduction to Git and GitHub. You will learn the basics of these tools and learn how to create a new repository on your local machine and on GitHub. You will also learn how to synchronize your local repository with the remote one on GitHub. Let’s get started!

    What is Git?

    Git is a distributed version control system designed to track changes in a project’s files. Git was released in 2005 by Linus Torvalds for the Linux kernel. Other kernel developers contributed to its development, and it has become the most popular choice for software teams. Git offers strong support for non-linear development and speed.

    Version control systems are a software tool that manage changes to a computer program, document, or collection of files. They help a user or a group of users track changes made to a project over time.

    Git works by saving a snapshot of the state of the project files at a certain time. It keeps the files that did get updated and references of the files that did change since the last snapshot. Git is essential to software development since most projects are developed by teams.

    Git is the de facto standard for version control. More than 87% of developers use Git as a control system. Any developer needs at least a base knowledge of Git to be successful and relevant to the market.

    Most companies, big and small, use Git as a repository, including:

    • Netflix
    • Reddit
    • Lyft
    • Shopify 
    • Facebook
    • Atlasssian
    • Google
    • eBay

    Git terminology

    What are Git states?

    Git has three primary states that it allows the project’s files to acquire. The three states are outlined below.

    • Modified: files that have been changed, but the changes have not yet been marked by Git. These changes won’t become part of the next snapshot.
    • Staged: the changes have been tracked by Git and will be marked as such in the next snapshot.
    • Committed: the changed files that have successfully become part of the latest snapshot.

    repository is a directory or folder where your project lives, and it can either be local (on your computer) or hosted online. It contains the entire codebase and its revision history. Popular online hosting services for repositories are GitHub, GitLab, and Bitbucket. We will learn more about GitHub later.

    What is Git commit?

    Think of Git like a tool that manages a timeline. Commits are the units that timeline, like milestones or events. With the commit command, we are creating those individual events.

    The commit command captures a snapshot of a project at a particular moment in development. Committed snapshots will not change on their own. Prior to the execution of git commit, we use the git add command to promote any changes that we will later store. Commit and add are the most popular commands.

    What is Git checkout?

    The git checkout command is a way of switching between branches or restores working tree files. Think of this as switching between different versions or features of a project. This command uses three entities: files, commits, and branches.

    What is Git clone?

    The git clone command is used to target a repository and copy it. You then have your own version of that repo and can start editing it without altering the original. In general, the original is held on a remote server, like GitHub.

    What is Git pull?

    The git pull command can be used to access and download files from a remote repository and update your local repository so it matches the updates to the original. Think of this like you’re merging your version and the original. The git pull command is made up of two commands: git fetch and then git merge.

    What is Git tag?

    Tags are a reference to a specific moment in a Git repo’s file history. Think of this like a branch that doesn’t change. Tagging allows you to mark important checkpoints in a project’s timeline (i.e. software version releases).

    Conclusion

    Let's end this part right here. We'll learn about Github in the next part as well as how to work with Git.
    Till then, stay tuned.

    0 Comments

    To add a comment, please Signup or Login