Git, who?
Tags: git, beginners, codenewbie, github
Published: 2020-07-17 04:22:46

For developers, git is the most essential tool for tracking code changes or files. Basically, it is a **must** to know when and how to use it. 


###What is Git? 

![Git](https://cdn-media-1.freecodecamp.org/images/1*TnsFDs-DEye722CrQXjv8w.png)


*Git* is a version control system written in C, Perl, Tcl and python. It is based on the Distributed Version Control System(DVCS), in which developers can easily access their data or code anywhere in the world. Git was created by Linus Torvalds. It was an initial release on April 7, 2005. 


Earlier days without Git, the developer's biggest problem is to share a big chunk of data within their team. Imagine, if your computer crashes or accidentally deleted into your folder which consists of all of the codes.  

![NO!!](https://media.giphy.com/media/l49JTUMDgDdf5wDde/giphy.gif)

It is big "oh no!" All your precious code all gone. 


With the help of Git, you can access your previous commit, save your current work and get back easily were you working on the next day. Revert your previous commit.  Collaborating with your team more often because it allows changing codes between the team members without a hassle. 


> In my personal experience, at first, it kinda uncertain to use because it's new for me and I think it is another thing I need to remember aside from coding. As time goes by, I've actually enjoyed using it. I appreciate it how convenient for any developer like me to use it all the time. 



###Well, how it works.

![how it works](https://media.giphy.com/media/3ohjV95sCHjXq5QoNi/giphy.gif)

Download and install the Git. You can download it from [here](https://git-scm.com/downloads)

After downloading Git into your machine, you visit [this](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) for your reference on how to install Git.


Here's some cheat sheet for you. 

**git init <directory>** - Create an empty repository directory. 

**git clone <repo>** - Clone repo located at <repo> onto local machine. The original repo can be located on the local filesystem or on a remote machine via HTTP or SSH.

**git status** - To check which are staged, unstaged, and untracked in your current branch.

**git log** - To check your list of previous and current commits.

**git commit -m message** - To commit your current adjustment with a specific message.

**git branch** - To check your current branch.

**git checkout -b branch-name** - Create and checkout it out the new branch.

**git merge branch-name** - Merge branch into the current branch.

**git fetch** - Fetch a specific branch

**git pull** - Pull the updated version of the specific branch and immediately merge it into your local copy.

**git push** - Push all your staged changes on the specific branch.

**git commit --amend** - Replace the last commit with the staged changes and last commit combined. Use with nothing staged to edit the last commit’s message.

**git rebase base-name** - Rebase the current branch onto the base. The base can be a commit ID, branch name, a tag, or a relative reference to HEAD.
**git reset** - Reset your staged changes to match into the latest commit.

**git reset --hard** - Reset your staged changes to match into the latest commit and overwrites everything on your current working directory.
 
**git diff HEAD** - Check the difference between your current code to the last commit.

________________________


##Let's wrap up things:
This article is all about Git and how we can work it the basic command. Maybe for the next article, I will share some of my Git Client you can use in the future. Remember, you can learn **ANYTHING** as long as you're open to accept and embrace it. Thank you for reading. 

Happy Coding! 


_______________________________________________________________

Reference: 
[Git cheat sheet](https://www.atlassian.com/git/tutorials/atlassian-git-cheatsheet) 
<span>Photo by <a href="https://unsplash.com/@timmossholder?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Tim Mossholder</a> on <a href="https://unsplash.com/s/photos/learn?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></span>