Git is Gud

Helmi Alfarel
4 min readApr 4, 2021

What is git? Git is basically a version control system (vcs) . Git tracks the changes that we make in a file, thus we know what we have done. Git also makes it easier to collaborate with our fellow software development team, because we can merge our code and their code into one source. Git also enable two person to work on different parts of the same file and later merge those change without losing each other’s work.

Since having basic git skills is a mandatory requirement of being a software developer, I’m going to show you a little bit of git routine that you can implement in order to develop your own project. There are many git service, among them is Gitlab. We’re going to use Gitlab as our git service.

First, git is a software that runs locally. So you need to install git on your local machine. You Second, you also need to make an account in git provider ( Gitlab ). Third, you need to make a project directory on your Gitlab account

Then after that, how can I start my project?

  1. You need to create a new local repository by using the command git init on your terminal
  2. Sync your local repository with your git account using the command git config — global user.name “your_username” and git config — global user.email “your email”
  3. Update your local repository so that your committed change can be saved in Gitlab using the command git remote add origin <your_repository_url>. By the way, you can replace origin with any other name. A lot of developers prefer the name origin for the sake of convenience.
  4. To update local repository with the changes that has been committed inside your Gitlab repository, simply just use the command git pull
  5. Use git add [filename] to add changes from your local repository. If you want to include all files inside your local repository, use git add . instead
  6. Do git commit -m ”Commit message” to store your changes plus giving comments to your change. Your commit message should be clear and readable.
  7. Finally, do git push [remote_name][branch_name].Since we named our remote as origin and we haven’t created any new branch, then the default branch will be master. Hence, git push origin master is the command
  8. Speaking about branch, to create a new branch, use git branch [branch_name]. To move from one branch to the other simply use git checkout [target_branch]. You can also use git checkout -b [branch_name] to create a new branch and directly move in it

There are other git commands that can be useful, such as:

git merge, integrate changes from two branch into one single branch

Git merge Master to Feature branch illustration

git rebase, this moves the entire branch to begin on the tip of the master branch, effectively incorporating all of the new commits in master. But, instead of using a merge commit, rebasing re-writes the project history by creating brand new commits for each commit in the original branch.

Git rebase Illustration

git stash, temporarily store changes you’ve made to your working copy so you can work on something else, and then come back and re-apply them later on

That’s all from me for today folks.

--

--