Git Terms Explained

So version control has been around for quite some time now, but in case you have never heard of git before…here is some info to help shine a light on the terms you might come across.

What is Git?

Git is a distributed version-control system or DVCS and it is used for tracking changes in source code during development. Git is designed for coordinating work among developers, but it can be used to track changes in any set of files. If you need a detailed git guide checkout the guides site from GitHub.

What is a Repository?

A repo or repository is in essence a folder that contains all the project files for a particular project. For example this could be for an api, a front end solution basically any development project you want to store in your repo. These can be made private so only the team or company working on them can have access…or they can be made public so everyone can branch from them.

In this post let’s say the name of the repo we are working on is called ingest-api, an api designed to handle inbound data into an application.

What do we mean by Clone?

Git clone simply allows you to take a copy of an existing repository. This cloned version sits locally on your machine. To clone the ingest-api

_>

git clone ingest-api

What is a Branch?

In nature, a branch comes out from a tree, the tree in this context represents the primary branch, from the tree, commonly known as the Master branch.

Developers can create branches off from the Master branch for a particular repository. This can be used when developing a new feature and its a good way of keeping changes separate during development. You may find this has a ticket in the branch name, something like OW-417-Setting-Up-Import. The ticket name can normally be found in a dev / product management tool, for example JIRA.

To create the branch use:

_>

git branch OW-417-Setting-Up-Import

How about Checkout?

So if you have created your branch online in git hub or in Bitbucket (for example), in your local version of the project, you will still be on the Master branch. So you’ll want to switch to the branch for the feature you are working on. The checkout command allows you to do this.

_>

git checkout OW-417-Setting-Up-Import

What is a Commit?

Once an engineer has created their branch for a particular feature, they will start writing code. Once they ready, they will “commit” their changes to the branch they are working on for that repo.

The command below shows an example. The -am option is split into two parts. The a flag to commit all changed files and the m flag to provide a commit message.

_>

git commit -am "a commit message"

In short this is a way of submitting or saving the changes the developer is making to the repo.

Fetch boy, fetch!

You use the fetch command when you want to get changes from an existing repository, for example when it has been updated.

What about Push?

Once you have made your commits and you are happy to push them up to the online instance of your version control system (for example git hub), the next stage is to push the commits to the branch in the remote repository.

In simple terms, this means your changes that are saved locally, will be saved online in your remote version of your branch.

Merging?

Ideally we like the branches we work on to make their way back to the Master branch, so we can release our code and new features to customers!

Merging is simply the process of combining the changes you have made in your new feature branch with the “live” code in the master branch.

To do this you make a PR.

What do we mean by PR?

A PR stands for, pull request, this is where you ask developers in your company or team to review the code changes you are making, so you can merge your feature branch, into the master branch, ready for the feature to be used in the real world.

Conclusion

And that’s some git terms for you explained. If you’d like to know more, check out the Udemy git courses. There are a bunch of courses on there to do with version control so take a look and keep those commits flowing 🙂

%d bloggers like this: