DEV Community

Cover image for Git, who?
Devstories Playground
Devstories Playground

Posted on • Updated on

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

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

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

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.

git init - Create an empty repository directory.

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.

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
Photo by Tim Mossholder on Unsplash

Image description

Top comments (0)