Git: Quick Explanation and Its Basic Implementations

Muhammad Urwatil Wutsqo
4 min readMay 10, 2022

--

What is Git?

Git is a version control system that is commonly used in software development processes. Then what is Version Control System? Version Control System is a tool in charge of recording every change to project files done by single or many people.

If you’re familiar with Google Docs, you might be aware that you can see every change made to the file and the time and who has changed it. It’s the same idea with Git but with more advanced features.

Installation

Git is available for all major platform, you can download and find the installation instruction on its official site: https://git-scm.com/

Git Commands

There are some basic commands that we will learn in this section, including init, clone, pull, push, etc.

Git Init

You can use git init to start a new repository.

Git Clone

git clone [repository url] [folder name]

If you already have a repository before, you can use git clone instead.

The foler name parameter is optional, you can leave it blank and it will create the folder with the same name of its origin repository.

Git Remote

git remote -v

You can use this command to see what is the remote repository name and its url.

Git Branch

This is to show what branches are there and what branch are you currently on.

Git Checkout

To change branch or create a new one, you can use this command.

Git Status

It is used to see the current status of our local repository.

Now let’s make a change to a file, then run the command again.

It will display what files are already modified.

Git Add

git add [file or directory]

It is you’re done with modifying your files, you can add the modified to the stage to be committed later. You can also use the shortcut git add . to add all changes to the stage.

Now, let’s run git status again.

We can see that the app.css file is now added to the staged status.

Git Commit

Use git commit -m "[insert the commit message here]" to save your changes.

Git Push and Pull

git pull [remote repo name] [branch name]
git push [remote repo name] [branch name]

Now that you commit your changes, you can synchronize your local repo with the remote repo using git pull and git push . The differences is that git pull is that you’re “pulling” the updates on the remote repository to your local repository, while git push is doing the opposite.

Git Stash

git stash

Let’s say you’ve edited some files but you don’t want to commit it yet but you also don’t want to delete all the changes. You can use git stash command.

git stash pop

You can use this command to restore the latest stashed changes.

Closing

There are a lot of other powerful command for more advanced user, but I think for now that’s enough to cover all the basic introduction for Git. I hope you’re learning something new and see you again next time.

--

--