GITing to know Version Control

Fajar Satria
Simpul Technologies
6 min readJan 31, 2020

In this modern time, there are a lot of people who still struggling with their habit to recreate new documents when a new revision come out. But without us knowing this habit is waste of time. Why? Because we did that again and again although we know there are just small of changes needed.

When you work as a team and you and your co-worker working on different task or feature. Then you need to submit your code and your co-workers also want to do same things. What would happen? You just messing around and check every line code and retesting again from zero? Oh come on and good luck!

So that’s why version control system is here, when we can track every single changes in our project and verify also. Example: when you want to submit your task so the project leader get notification and aware that you made some changes. Then they review your task and give feedback or if your task pass their QA they can deliver that feature to customer immediately.

Illustration of SVN

Okay, here’s another example: when you want to submit your code and your college need to do new task but also need what feature you developer before, so they need to pull or download your changes from documents. Because they cannot submit what they did before download or get last update from latest documents.

There are few technology for VCS a.k.a Version Control System and big corporate behind them. But I just want to talk about one: git.

Okay, let’s talk little a bit about git story. It’s develop by original creator of linux kernel, Linus Torvalds who gave up access to BitKeeper, a proprietary source-control management (SCM) system that they had formerly used to maintain the project.

Linus Torvalds wanted a distributed system that he could use like BitKeeper, but none of the available free systems meet his needs. Torvalds cited an example of a source-control management system needing 30 seconds to apply a patch and update all associated metadata, and noted that this would not scale to the needs of Linux kernel development, where synchronizing with fellow maintainers could require 250 such actions at once.

Okay let’s messing around. Git has some commands corresponding to specific task.

git clone

  • Git clone to copy a git repository from remote source, also sets the remote to original source so that you can pull again.

How To :

git clone <Url of Git Repo>

git status

  • It is very useful to check the status of files you’ve changed in your working directory; i.e, what all has changed since your last commit.

How To :

git status [<options>…​] [--] [<pathspec>…​]

git add

  • It used to add changes to stage/index in your working directory.

How To :

git add [--verbose | -v] [--dry-run | -n] [--force | -f] [--interactive | -i] [--patch | -p]
[--edit | -e] [--[no-]all | --[no-]ignore-removal | [--update | -u]]
[--intent-to-add | -N] [--refresh] [--ignore-errors] [--ignore-missing] [--renormalize]
[--chmod=(+|-)x] [--pathspec-from-file=<file> [--pathspec-file-nul]]
[--] [<pathspec>…​]

git commit

  • To commit your changes and sets it to new commit object for your remote.

How To :

git commit [-a | --interactive | --patch] [-s] [-v] [-u<mode>] [--amend]
[--dry-run] [(-c | -C | --fixup | --squash) <commit>]
[-F <file> | -m <msg>] [--reset-author] [--allow-empty]
[--allow-empty-message] [--no-verify] [-e] [--author=<author>]
[--date=<date>] [--cleanup=<mode>] [--[no-]status]
[-i | -o] [--pathspec-from-file=<file> [--pathspec-file-nul]]
[-S[<keyid>]] [--] [<pathspec>…​]

git push/git pull

  • Make changes to remote after you have added and committed your changes and you want to push them, or after your remote has updated and you want those latest changes.

How To Push :

git push [--all | --mirror | --tags] [--follow-tags] [--atomic] [-n | --dry-run] [--receive-pack=<git-receive-pack>]
[--repo=<repository>] [-f | --force] [-d | --delete] [--prune] [-v | --verbose]
[-u | --set-upstream] [-o <string> | --push-option=<string>]
[--[no-]signed|--signed=(true|false|if-asked)]
[--force-with-lease[=<refname>[:<expect>]]]
[--no-verify] [<repository> [<refspec>…​]]

How To Pull :

git pull [<options>] [<repository> [<refspec>…​]]

git branch

  • Its use is to show all list in the branches.

How To :

git branch [--color[=<when>] | --no-color] [--show-current]
[-v [--abbrev=<length> | --no-abbrev]]
[--column[=<options>] | --no-column] [--sort=<key>]
[(--merged | --no-merged) [<commit>]]
[--contains [<commit]] [--no-contains [<commit>]]
[--points-at <object>] [--format=<format>]
[(-r | --remotes) | (-a | --all)]
[--list] [<pattern>…​]
git branch [--track | --no-track] [-f] <branchname> [<start-point>]
git branch (--set-upstream-to=<upstream> | -u <upstream>) [<branchname>]
git branch --unset-upstream [<branchname>]
git branch (-m | -M) [<oldbranch>] <newbranch>
git branch (-c | -C) [<oldbranch>] <newbranch>
git branch (-d | -D) [-r] <branchname>…​
git branch --edit-description [<branchname>]

git checkout

  • Its use is to switch to different branches.

How To :

git checkout [-q] [-f] [-m] [<branch>]
git checkout [-q] [-f] [-m] --detach [<branch>]
git checkout [-q] [-f] [-m] [--detach] <commit>
git checkout [-q] [-f] [-m] [[-b|-B|--orphan] <new_branch>] [<start_point>]
git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <pathspec>…​
git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] --pathspec-from-file=<file> [--pathspec-file-nul]
git checkout (-p|--patch) [<tree-ish>] [--] [<pathspec>…​]

git merge

  • Merge two branches you were working on; usage: switch to branch you want to merge everything in and do git merge.

How To :

git merge [-n] [--stat] [--no-commit] [--squash] [--[no-]edit]
[--no-verify] [-s <strategy>] [-X <strategy-option>] [-S[<keyid>]]
[--[no-]allow-unrelated-histories]
[--[no-]rerere-autoupdate] [-m <msg>] [-F <file>] [<commit>…​]
git merge (--continue | --abort | --quit)

git stash

  • This command is used to save changes that you don’t want to commit immediately.

How To :

git stash list [<options>]
git stash show [<options>] [<stash>]
git stash drop [-q|--quiet] [<stash>]
git stash ( pop | apply ) [--index] [-q|--quiet] [<stash>]
git stash branch <branchname> [<stash>]
git stash [push [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]
[-u|--include-untracked] [-a|--all] [-m|--message <message>]
[--] [<pathspec>…​]]
git stash clear
git stash create [<message>]
git stash store [-m|--message <message>] [-q|--quiet] <commit>

You could read more in git documentation in git-scm.com/docs.

That’s it some basic commands in git. So are you interested? Do you want to use them in your future projects? Tell me about your thoughts below.

--

--