Introduction To GIT

A Version Control System (VCS) lets you keep a track of your work and save your work across pages.

The best case of a VCS is working on a software project. To produce a result, you may have to work with various files. You can save the files in a single commit. Whenever someone else in the team wants to view the changes made, they can view the commit. If you want to revert the changes made, you can roll back the commit. The VCS helps you to develop various versions of code at the same time, with merging possible later on.

GIT

Git is a popular VCS that keeps a track of all the modifications you have made to your code. If an issue arises with a new feature, you can trace where it went wrong or rollback to the previous changes with ease.

Git is not an ordinary Version Control System. It’s a distributed VCS, which means that every collaborator of the project can have a history of the changes made in their local system and others can work on different features of the project without the hassle of communicating with the remote version of the project. This makes managing the project super-efficient and the changes can be merged with the local copy.

Git provides buffers before saving the project. The speed and integrity of Git are well maintained since its launch. The best examples of Git platforms are GitHub, GitLab, BitBucket etc.

GIT Terminologies

Repository

Repository, or Repo, is a folder containing all the files related to the project and the history of the revisions made. There are two repositories that you will have during the lifetime of a project. Remote and Local repositories.

The remote repo grants access to the other developers, either public or a private team, who will be able to see and use work with the project. The repository resides in the server of the Git platform.

Local repo is a copy of the remote repo residing on your machine. the changes made will reside in the local repo and others will not be able to see it unless you push it to the remote repo.

Cloning

Cloning means creating a copy of the remote repo to your local machine to work on. When you are working on a project and you need a copy of the current code, you clone the repo to your local machine. Now, you will be able to work on the project from your local machine.

The code to clone a repo is:

git clone <Repo-URL>

Commit

Committing in Git means saving the changes made to the repo. When working on a project, to make the changes in the local repo, commit the changes made. Then, push it to make the changes in the remote repo. To commit the changes, follow the code:

git commit -m ” “

Push

Once your local changes are committed, you have to push the changes to the remote repository. Push command transfers the changes made in your local repo to the remote repo. Now, all the fellow developers will have access to the change and can edit it. To push the changes, follow the command:

git push origin <branch>

Pull

Pull command is the straight opposite of the push command. It lets you copy the code from the remote repo to the local repo. If a fellow developer makes changes to the code and they push it to the remote repository, you need to pull the changes to your local repository to start working on them. To pull the code, follow the command:

git pull <remote-repo>

Branch

Branches in Git are a pointer to a snapshot of your change. The git branch command lets you do various operations on branches like create, list, rename, and deletion.

To list all the branches in your directory, run the following command:

git branch

To create a branch:

git branch <branchname>

To delete a branch:

git branch -d <branchname>

Merge

Merging in Git means to unite the forked history back together. Merging lets you take the changes committed in a branch and lets you integrate them with another branch, resulting in a single branch.

Conclusion

The entire topic of Git is a vast and broad one. However, this is the basic introduction to Git for you to start working. When it comes to software development, Git is a very vital tool one should know. Every software development company uses any platforms of Git like GitHub, GitLab or BitBucket when they are collaborating as a project for improved teamwork. Git is a must-know for any software developer.

2Base is a full-service Interactive Digital Agency that offers creative, strategic and technical development of wide range of products and services.