Let’s “Git” Started! : A guide to git

Image source : perforce.com


  • Git Init
git init
git remote add origin https://gitlab.com/audillaputri/test.git
git remote -v
  • Git Clone
git clone https://gitlab.com/audillaputri/test.git#Clone a repository into a directory with a custom name
git clone https://gitlab.com/audillaputri/test.git custom-director

Track and Stage Files

#To track only one file
git add file1
#To track all files
git add .
git status


  • [RED] is used when you want to commit a test that is destined to fail as there hasn’t been any implementation
  • [GREEN] is used when you have implemented the code for the test and expect it to pass
  • [REFACTOR] is used when you want to make a few changes in the code. Note that the changes shouldn’t make the passed test to fail.
  • [CHORES] is used when you want to make some changes that is unrelated to functionality such as resizing a picture, changing fonts, et cetera.
git commit -m "Commit message"


git push origin master


git revert 


git pull origin master


git branch new-branch
git checkout other-branch# Create a new branch and immediately switch to it
git checkout -b new-branch
$ git branchmaster
* new-branch
# Delete a branch if it has been pushed
git branch -d "new-branch"
# Delete a branch that has never been pushed
git branch -D "new-branch"
  • Main will be the branch we use when all is set and ready to deploy.
  • Staging is a branch that combines all of the developers work. This branch is used to demonstrate the product in sprint review.
  • PBI-[1,..,n] is the branch used to store the product backlog items of a sprint.
  • Hotfix is a branch from the master branch that will be used to bug-fixing.
  • Coldfix will be used if the product owner rejects one or more PBI that has been implemented. In order to fix that, we need to do a rollback and we do it on this branch.
$ git checkout master
$ git merge new-branch




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store