Git, who?

Photo by Yancy Min on Unsplash

Git, who?

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 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.

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.

  • Download and install the Git. You can download it from here

  • After downloading Git into your machine, you visit this for your reference on how to install Git.

Here's some cheat sheet for you.

  1. git init - Create an empty repository directory.

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

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

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

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

  6. git branch - To check your current branch.

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

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

  9. git fetch - Fetch a specific branch

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

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

  12. 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.

  13. 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.

  14. git reset --hard - Reset your staged changes to match into the latest commit and overwrites everything on your current working directory.

  15. 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.

HAPPY CODING 🚀