Introduction to Git By Syukri – Tarsoft

GIT

Share on facebook
Share on google
Share on twitter
Share on linkedin

What is Git, what are the importances and how to use it?

What is Git?

Git is a tool used for code management. Git can be used for free. Git is very synonymous in handling code projects whether on small-scale or large-scale projects efficiently. This is because Git is used to look and identify every change that occurs to the code and Git allows more than one developer to work together to develop each project simultaneously.

In Git, every developer can make their own changes to the code. From that, other developers can see and track the changes and can learn what the changes are and can proceed to what they can do next. Some of the changes might have some bugs or untidy written code. So, other developers can communicate with the developer that changes the code to fix the code again in order to produce a single code that is good to read, understand and maintain in the future.

Scenarios in Git

This is a scenario in using Git. Let assume there are 3 developers while developing a project which are Developer 1, Developer 2 and Developer 3. Every developer can make their own changes to the code. Let’s say Developer 1 has made changes. Developer 2 and Developer 2 tracked the changes and found some bugs on the changes code. Then, Developer 2 communicates with Developer 1 and tells Developer 1 that the changes still have something to fix. But at the same time, Developer 3 has the solution to fix the code, so Developer 3 requests to fix the changes and the code finally has been as good as they planned. Thus, that is one of the normal scenarios that occurs while using Git.

Importance of Branch

In Git, there are many features that one as a programmer or developer can use. One of them is branch. Branch in Git used to keep changes until they are ready. One can create their own working branch and can do their work on that created branch while the main development branch remains stable. Then, if the project has been confirmed successfully done and ready to deploy to the server, merging the created branch with the main branch can be done. One of the reasons why branch is good to implement is to avoid too many conflict codes in the main branch.

How to Install?

Configure tooling

First what you need is to install the Git. Check the link git-scm.com to download the Git based on your platform.

This step is to configure the user information for all local repositories. Below are the command that you need to know:

$ git config –global user.name “[name]”

Sets the name you want attached to your commit transactions

$ git config –global user.email “[email address]”

Sets the email you want attached to your commit transactions

Branches are an important part of working with Git. Any commits you make will be made on the branch you’re currently “checked out” to. Below are the command that you need to know:

$ git status

To display the state of the repository and staging area

$ git branch [branch-name]

Creates a new branch

$ git checkout [branch-name]

Switches to the specified branch and updates the working directory

Branches

Create repositories

When starting out with a new repository, you only need to do it once; either locally, then push to GitHub, or by cloning an existing repository. Below are the command that you need to know:

$ git init

Turn an existing directory into a git repository

$ git clone [url]

Clone (download) a repository that already exists on GitHub, including all of the files, branches, and commits

Synchronize your local repository with the remote repository on GitHub.com. Below are the command that you need to know:

$ git push

Uploads all local branch commits to GitHub

$ git merge

Combines remote tracking branch into current local branch

$ git pull

Updates your current local working branch with all new commits from the corresponding remote branch on GitHub.

Synchronize changes

Make changes

Browse and inspect the evolution of project files. Below are the command that you need to know:

$ git add .

Snapshots the file in preparation for versioning

$ git commit -m “[descriptive message]”

Records file snapshots permanently in version history

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top