Git, Programmer’s Best Friend
If you are a programmer working on a project in teams then you must have heard(or even use it) what Git is, however for those who don’t know what Git is then after reading this blog you will be able to plan your project , and essentially finish your project with ease.
So What Is Git?
Git is a free and open source distributed version-control system, meaning that Git can store your code and track it’s content.Furthermore for every time you put your code to Git(in Git term it is called commit), it will not delete your previos code but saved in a different history so that users can easily know the changes. Another feature is that the code is also distributed into all the team member’s local repository and saved in the central server.
Why Do We Use Git?
A project usually have a team of programmers working on it and most cases they work divided into tasks and therefore working in parallel. This can lead to code conflicts if there are 2 tasks that are connected, leading to more time needed to find and finish it. However by using Git, the code will be easily tracked so high chance there will be no code conflict and if there was a conflict(usually by merging) Git can highlight what was changed and compares with the old version of the code which saves up time.
How Do We Use Git?
After installing Git, right click on the project folder and there will be an option name “Git Bash Here”, click it and a terminal will be opened. Make the local repository by initializing the Git in the folder by using git init . After making the local repository there will be new git commands that to be used, I will mainly explain the basic commands for Git.
Git Pull
Git pull command is used to get and download the remote repository and update it to the local repository to match the contents. It is usually used to merge the remote repository and the local repository to implement new codes.
Git Push
Git push command is used to upload the content in the local repository to the remote repository. We can specify which branch and repository we can push to.It is usually used after finishing an implementation in a project so that other teammates would be able to connect it with their parts.
Git Clone
Git Clone command is to clone an existing repository in a new directory. It is usually used for initializing a directory or downloading data.
Git Merge and Git Rebase
Git merge command is used to join 2 commits into the local repository, it is usually used to implement new codes on an existing work in a project. There is another function that does similar to git merge called git rebase, which combines commits and transfer it to a new commit.
Git Revert
Git Revert command is used to record new commits, however the recorded commits are previous commits that have already been in the history. Thus “reverting” back to the commit before any changes happened to the targeted commit.
Git Stash
Git stash command is used to record the current state of the working directory , but you want to go back to a clean working directory. It is then saved to your local modifications and reverts to the current commit head.
Git Remote
Git remote command is used to connect to repositories in the internet. This includes creating,viewing and deleting the connection of the repository.
Git Branch
Before explaining what the command does, we need to know what a branch is. Branch is a way to copy a working directory into a new commit and can work there without worrying affecting the original directory, it is usually used for parallel working, so git branch command is used to make,delete and view those branches.
Git Checkout
Git checkout command is used to navigate through your branches.Checking out a branch also updates the commit in the working directory to match the version stored in the branch.
Did I Use Git in My Project?
Yes 100%, without git me and my teammates would not have finished the first backlog in 1 week. By dividing backlog into tasks and working in parallel to my teammates it is faster and more efficient because git helps tracking commits and merges and this makes us easily keep track of my tasks and also my teammates tasks.