Krisna Ihsani

Mar 21, 2021

8 min read

Gitting Gud in Collaboration with Git: A Casul’s Guide

ah yes, the real version control


example of git tree structure that has master, hotfix, release, etc branch (

Common Commands Tutorial



git init 
#This command will clone the main branch of a repository
git clone <repository_url>
#This command will clone particular branch of a repository
git clone <branch_name> <repository>

Setup Identity

#This will setup the username
git config <your_username>
#This will setup the email
git config <your_email>

Connect your local git with repository git

git remote add <repo_identifier_on_local> <repository_url>

Add files to your change

#Add all files in the current working directory
git add .
#Add single file
git add <file_name>
#Add multiple files
git add <file1> <file2> <file3> <filen>

Commit a change

git commit -m "<commit_message>"
git commit --ammend -m “<new_commit_message>"

Save Your Progress Without Marking It

#Before jumping into another branch execute this command
git stash

#this will continue the last progress and drop it from the progress stack
git stash pop
#this will continue the last progress without dropping it from the progress stack
git stash apply
#this will throw away the last progress
git stash drop

Synchronize The Local Git

git pull origin <branch_name>
git fetch <remote-identifier> <branch>

Store Your Changes to Online Repository

git push origin <branch_name>#Usually I use this command to make local branch linked with the remote branch
git push -u origin <branch_name>
please avoid executing this command as possible

Create & Delete Branch

#Make new empty branch
git branch <new_branch>

#Make new branch that is derived from current working branch
git checkout -b <new_branch>
git branch -d <branch_name>#Force delete a branch
git branch -D <branch_name>

Move To Another Branch

git checkout <branch_name>

Check Commit History

git log

Undo Commit
#Revert to a certain commit
git revert <commit_hash>
#Reset to a certain commit
git reset <commit_hash>

Combine Two Branches
#Normal merge
git checkout <target_branch>
git merge <source_branch>
#Merge with squash
git checkout <target_branch>
git merge --squash <source_branch>
git checkout <source_branch>
git rebase <target_branch>
git checkout <target_branch>
git merge <source_branch>

Git Flow in Software Engineering Project

  1. master/main: location of the production-ready code
  2. development/staging: location of the development code
  3. feature: location of the implementation of a certain feature
  4. coldfix: location of the bugfix for the staging branch
  5. hotfix: location of the bugfix for the master branch
Git Flow in PPL 2021
  1. [RED] <description>: Commit that contains testcase stuffs
  2. [GREEN] <description>: Commit that contains implementation
  3. [REFACTOR] <description>: Commit that contains refinement of the code that doesn’t break the logic
  4. [CHORES] <description>: Contains non-functional stuffs & grunt tasks
our backend branches
commit examples