Git 101 — Pushing, Pulling etc.

Are we playing kite now?

Muhammad Naufal Irbahhana
HappyFresh Fleet Tracker
4 min readOct 3, 2019

--

Is this what my son usually says when he slays noobs online?

NO! Git is a distributed version-control system for tracking changes in source code during software development. It is designed for coordinating work among programmers, but it can be used to track changes in any set of files. In a nutshell, git stores your codes so that other people can collaborate with it.

In this quick and simple guide, i will teach you how to get good at git! There are a lot of git commands that will help you through your software development process, but you have to start from somewhere! So the commands i listed below will probably help you who are new to git.

What you need to start:

  1. A working computer
  2. A terminal/cmd/powershell idc
  3. Willing to learn
  4. Time

Let’s jump into it!

0. git init

The git init command creates a new Git repository. It can be used to convert an existing project to a Git repository or initialize a new, empty repository. Without doing init, we most likely can’t do all the git command below. so do INIT in your targeted folder!

  1. git pull

This command will fetch from and integrate with another repository or a local branch. Basically by invoking git pull, we will download the code from targeted repository and save it in our machine for development. In its default mode, git pull is shorthand for git fetch followed by git merge FETCH_HEAD. So here [<options>] specify the remote repository , and the [<repository>] is the branch you targeted.

2. git push

The push command will update remote repository along with associated objects. So git push will upload the code to your repository that is configured by you before. For the time being, you only need to know how to push to your own repository and branch. So here [<options>] specify the remote [<repository>] , and the repository is the branch you targeted.

3. git clone

You can use git clone when you want to initialize a project by cloning available repository. There are 2 ways of cloning, using SSH and HTTPs. But you (guessing you’re a student like me) would probably be more familiar with HTTPs, so to clone using HTTPs we use the command. Getting the repository link is easy. If you have access to that repository, you can find it in top right of the window, that says clone with HTTPs. Look for a link that ended with .git

4. git commit

This is also important for development, git commit will record the change on your repository. It tracked on what you add, what you delete, and everything that you change. It really helps on doing group project, you can see your friend’s work in almost real time. It also have a commit message that can describe what you are doing in your pushed code.

5. git add

git add is essential because before you can commit your work, you have to add it first. Technically, it add file contents to the index. The “index” holds a snapshot of the content of the working tree, and it is this snapshot that is taken as the contents of the next commit. the ‘ . ’ argument is for adding all files that you change to the index.

This five git command is the most essential command. And probably what you will use the most. I will also explain a bit about other commands bellow.

git merge helps you combine two of pushed history into one commit.

git branch shows the branches of the repository being worked on locally.

git rebase specializes in integrating changes from one branch onto another. The other change integration utility is git merge .

git revert used to record some new commits to reverse the effect of some earlier commits (often the one you got it wrong)

git stash temporarily put what you are working on, that you have not push into a temporary place, so that you can work on other thing first without having to commit/push it.

git remote have several usage, depending on what you need. It can add or remove an online repository so that we can work on multiple project with different repositories.

git checkout switches your current branch to a local or a tracked remote branch

As easy as it seems! You can do all this commands directly, yeah like right now! right right now! Using git will boost your team’s productivity and concurrentness. So stop reading and start practicing!

it’s late and my head is spinning.

ciao!

--

--