Get Good With Git

More Git Commands

git branch

  • git branch <branch_name> to create a new branch with <branch_name> as the name.
  • git branch -d <branch_name> to delete a branch.
  • git branch -m <old_branch> <new_branch> to rename a branch

git checkout

  • git checkout <branch_name> to switch to <branch_name> branch.
  • git checkout -b <branch_name> to create a new branch with the name <branch_name> and switch to the new branch.

git remote

  • git remote add origin <URL> to add a remote named origin for the repository at <URL> .
  • git remote remove <name> to remove a remote named <name> .

git clone

  • git clone <url> to clone the remote repository to a directory named
  • git clone <url> . to clone the remote repository to current directory.

git push

  • git push origin <branch> to push <branch> to origin remote.
  • git push -u origin <branch> is similar with previous command, but will also set the upstream as origin/<branch> .
  • git push to push the current branch to its upstream. It will output an error if the upstream has not been set.

git pull

  • git pull origin <branch> to pull changes from remote branch <branch> from origin remote to your current branch and merge it.
  • git pull is similar with the previous command but will pull changes from the upstream that has been set. It will output an error if the upstream has not been set.

git merge

  • git merge <branch> to merge <branch> with the current branch.

git rebase

  • git rebase <branch> to move current branch’s commits that is not in <branch> history to <branch>. For
If currently at "topic" branch:      A---B---C topic <- HEAD
D---E---F---G master
If you run command: git rebase master
The result would be:
A'--B'--C' topic <- HEAD
D---E---F---G master
  • git rebase -i <commit> to pick, squash, or revert commits at once. the -i stands for Interactive.

git revert

  • git revert <commit> to remove <commit>. For illustration:
A---B---C---D master <-HEADIf you run command: git revert B or git revert HEAD~2
The result would be:
A---C'--D' master <-HEAD

git stash

  • git stash to store the changes.
  • git stash list to view stashed changes.
  • git stash pop to get the last stashed changes and apply it to the current branch.
  • git stash drop to delete the last stash.

Git Flow

Source: Panduan Git PPL 2021.pdf
  • master : the main branch that is stable and deployed to the production environment.
  • staging : the main branch where every developer will merge to before it is merged to master and deployed to production environment.
  • PBI-n : the branch that developers create and implement each Product Backlog Item, where n is the PBI number.
  • hotfix : the branch to quickly fix master branch when a bug is found in the production environment.
  • coldfix : the branch to fix or rollback changes in the staging branch if the product owner cancels a Product Backlog Item.

My Experience


  • Panduan Git PPL 2021.pdf
  • Panduan Git Flow PPL 2021.pdf



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