Git Explained

Git Explained
by Miguel Norberto

Linus Torvalds created git in 2005.

Git is a distributed revision control and source code management system emphasizing speed, data integrity, and support for distributed non-linear workflows.

History: How git was created

In 2005, Linus Torvalds managed a vast software project called the Linux kernel. The project was overgrowing and had become difficult to manage. To make the task more manageable, Torvalds decided to create a tool called git. Git is a software tool that helps developers track changes to their code. Git allows developers to work on projects together by tracking each developer’s changes. Git also allows developers to merge their changes easily.

Workflow: The basics of using git

If you’re new to git, the workflow can seem a little confusing at first. But once you get the hang of it, git becomes a powerful tool for managing your codebase.

Git workflows involve using one or more local repositories and a remote repository in its most basic form. Your local repositories are where you do your work - adding, editing, and deleting files. The remote repository is where you store your codebase and share it with other developers.

You’ll need to create a local repository and clone the remote repository to your computer to get started. From there, you can start making changes to your codebase. Then, you can commit them to your local repository when you’re done making changes and then push them to the remote repository.

If you want to collaborate with other developers, you can add them as collaborators on the remote repository.

Branching: How to use branches in git

In git, a branch is a named divergence from the mainline of development. Once you create a branch, you can switch between it and the mainline of development as often as you like. In git, there are three types of branches: local, remote tracking, and named branches.

A local branch is created on your computer. It is associated with your repository and tracked by git. You can have many local branches, but only one can be active at a time.

A remote-tracking branch is created by git when you clone a repository or pull from a remote repository. It tracks the location of a remote branch, but it is not associated with any particular repository.

A named branch is not created by default; you must explicitly create it using the -b flag of git checkout or git branch.

Merging: How to merge changes into your project

Merging is incorporating changes made in one branch of a Git project into another branch. There are a few ways to merge changes into your Git project.

The simplest way is to use the “git merge” command. This command will merge the changes from the other branch into the current branch. If there are conflicts, git will stop and ask you to resolve them.

Another way to merge is to use the “git rebase” command. This command will replay all of the commits from one branch on another branch. This can be useful when you want to move a branch up or down in relation to another branch.

The “git pull” command can also be used to merge changes from a remote repository into your local Git repository.

Git and GitHub: Using GitHub for collaboration

Git and GitHub are two very popular tools used for software development. Git is a version control system that helps you track changes to your code, while GitHub is a web-based hosting service for Git repositories.

So, what’s the big deal about Git and GitHub? One of the biggest benefits of using Git and GitHub together is that they make collaboration a breeze. With GitHub, you can create a repository for your project and invite other people to collaborate on it. This makes it easy for people to contribute to your project and helps keep everything organized in one place.

If you’re not already using Git and GitHub, I highly recommend giving them a try! They’re both powerful tools that can help make your software development process much more manageable.

Final Thought

Git is a powerful tool that has revolutionized the way developers work. While it has some drawbacks, the pros overwhelmingly outweigh the cons. Git is here to stay and will continue to be popular among developers for years to come.

Subscribe to Miguel Norberto

Sign up now to get access to the library of members-only issues.
Jamie Larson