Git Terminologies Explained

One thing I realized after I learned programming is that I can't avoid Git, a tool to track all changes in source code. Developers must be able to collaborate with their colleagues or even unknown persons in an open source project.

Even if you build something on your own, Git is really advantageous to record all stages of your development. Git is very useful when you learn a programming language as well.

When I learned Django, I made a small mistake that caused a form unable to send data into the database. I replayed the video tutorial to track the error, but I couldn't find it. Finally, I compared my Git commit with the tutor's Git on github side by side and I could spot the error immediately.

Another thing I found out is that Git has so many terminologies which can be somehow hard for new users to understand.

I got confused between pull and push or branch and fork when I started using this tool. It seemed that there is a specific term for a certain act. Unfortunately, there are so many distinct actions that I didn't know in detail.

Don't be overwhelmed by all jargon you find around Git. A little explanation is all you need for you to understand what each Git terminology means.

Enroll Nanodegree in programming (HTML, CSS, Python and JS) Now!

Understanding Git Terminologies does come with a number of benefits. Even if you develop a program alone, you can execute the right process to advance or fix your code.

Git terminologies explained:

Version Control

Version control keeps records of all changes taking place on a single or a collection of files during the development. This will allow you to recollect specific versions when you need them.

A version control system (VCS) will not only enable you to go back to a previous version, but also review all changes that have been made over time, identify who made modification that cause an issue, who reported an issue and when did he/she do that. In essence, if something terrible happened to your project, you can restore the file conveniently. 

Repository

A Git repository is simply a virtual storage that keeps all the files, folders, the versions of files, commits, deletions and other information. Git repository is a sub-directory inside the project directory and it has name .git. To create a git repository, you can run the git init command inside your project directory.

This is your local repository or a repository inside your own computer. If you want to share with your friends, you must first save your project into a remote repository. It can be a public web hosting service like Github or Bitbucket or your own private server.

Once you create a repository, it doesn't automatically save and track changes you make on your project. You must add files and then commit in order to save a version of your work.

Git Terminologies Explained

Remote

A remote in Git is a shared repository used by all members of the team to exchange their changes. It is commonly stored on a git hosting service like GitHub.


You can manage your connection with the remote repository by using the git remote command. This command is not a direct link into other repositories, it is only a bookmark that serve as convenient names. This way, you can avoid reverencing the repo by using complicated and long URL.

Origin

This is used to refer to the original repository. It is a default name given to the original remote repository that you clone. In short, ‘origin’ is the alias of your main remote repository name. 

Commit

Git commit is a command to save changes you made to your local repository. However, you must be aware that the change you made to a file won't automatically be included to the next commit. You need to always run git add command beforehand, to point out which changes are included to the next commit.

Another thing you should know is that you can exclude files or sub-folders inside your project from your commit. To do so, you can create a gitignore file and put all excluded files or folders into the list.

HEAD

This is a reference variable that refers to the last commit of the branch where you are in at the moment. Whenever any new commit is added, HEAD becomes the new commit.

Branch

A branch in Git can be seen as a “line of development.” It is a label for a certain commit and all the previous commits that it inherits from.

You can also see a branch as another version of your project which diverges from the primary working project. You can create a different branch to add new features or try fixing bugs without messing with the main branch.

Git's branching model is known as its 'killer feature'. Other VCS tools have costly branching processes. Some of them require you to make a new copy of your project directory. It is a tedious job when you have a large project.

In contrast, His an astonishingly lightweight branching process. You can create a new branch instantaneously, and it is so easy to switch between branches. 

Master

The term refers to the main (default) branch of every repository. Every change that has been done and accepted needs to be on that master branch. 

Push

Git push is an act of sending your latest changes to the remote repository. When you are 'pushing' your commits from your local repository, your remote repo is becoming sync with your local. In other words, the remote repo is not updated automatically, you must perform git push command to make it updated.

Pull/Pull Request

This is the opposite of git push. Git pull is retrieving the latest update from the remote repository to your local repo and immediately update the local repository to match that content.

When working on your project, sometimes people are duplicating your work to their own repository and make some changes. When they think that their work is worth adopting, they cannot push it to your repo.

All they can do is sending a pull request to you. Then you might decide to review the changes before pulling it to your main branch. If you satisfy with the their development, you can pull their latest commit to your repository.

Fetch

Git pull is a command that consists of two actions, git fetch and git merge. You can perform git fetch and git merge separately if you want to know every single detail of changes you've brought to your repository.

Unlike Git pull, Git fetch will only download and copy the latest update from a remote repository into your local repository. Fetching is a safer way to review commits before incorporating them to your local repo.

Git separate fetched content from prevailing local content, it has no impact to the local development. Use the git checkout command to explicitly checked out the fetched content.

Merge

Git merge command allows you to join multiple sequences of commits into a single line of development. It is mostly applied to combine two branches into one. The current branch will be updated, but the source branch will not be affected.

Start learning Python from UNLIMITED Books, Videos and Tutorials!

Cherry pick

Sometime things don't go as you planned, the code you write is broken. Luckily, one of your friend who works on different branch has fixed the problem. You can then cherry-pick your friend's commit and add it as a new commit onto your branch. Your newly cherry-picked commit will have a new commit ID on your branch.

Clone

This is an act of copying an existing git repository from a remote server to your local computer. In this way, you will have a full version of that git repo and can start working separately. Certainly, if you feel that your later development is valuable, you can send a pull request to the 'origin' repository.

Fork

A fork is simply a duplicate of a repository. Forking will give you with a new server-based repository. You will have two Git repositories at your disposal and allows you to do free experiment without affecting the original project.

You make fork of a repository so that you can propose changes to someone else's project or to develop someone else's project into your own distinct project.

Tag

Tagging in git is used to mark specific points in the development history. Predominantly, git tag is used to point a version release. You can also put a git tag in any point of your code development. This will make things easier for you to refer at any future time especially when you need to restore your data.

Stash

Git stash is a life saver when you ave some changes that you're not quite ready to commit but you want to leave your current work for a while. Maybe you want to switch branches or revert back temporarily to where it was that you started.

By using git stash, it will save your half-done work in a temporary place. When you've done with your different works, you can go back and recall it conveniently.

Rebase

Similar to git merge, git rebase is used to integrate changes from one branch into another. However, rebase has powerful history rewriting features. It transfers the completed work from the source branch to current branch.

Rebase combines a sequence of commits to a new base commit. It compresses the changes into a single line of history and unwanted history is eliminated.

Python Learning Roadmap: How to Avoid Mistakes I Made

Index

The index is also known as the staging or working Git area. Changed, deleted or added files are always stored in the index to a point when the files can be committed. To determine what is present in that Git index, simply use the Git status option. Green files represent these which have already been staged awaiting to be committed. On the other hand, red files are yet to be added.

Conclusion

Getting to know what GIT terms refer to is really essential for programmers. The above terminologies will really be of much help to you in becoming a developer. A couple of terminologies have similar meaning in English, but they specify different processes in Git. By reviewing each explanations carefully, you won't be confused anymore.

You can learn and master git by using Version Control with Git book. The step by step tutorials from book will make you fully grasp the power of Git for tracking, branching, merging, and managing code revisions.


0 Comments