Have you ever created an application project, then saved it with a folder name like project-final, then the next day because there was a revision from the lecturer or client it changed to project-final-revision, then the day after that it became project-final-last-real-revision?
If your answer is yes, congratulations! You are not alone. Almost everyone who has ever come into contact with the world of coding, from students who are writing their thesis to developer beginners, has committed this little sin. Manual methods such as copy-paste this folder might work if you work alone and the project is still small scale.
But, just imagine if you are building a medium-scale application, for example creating a single Tuition Payment Information System (UKT) or a complex Point of Sale (POS) application, and you have to collaborate with developerother. Manually merging code files from several different computers is the ultimate recipe for headaches and a series of errors.
This is where Git comes in as a hero without a cape.
This article will thoroughly and in-depth discuss basic Git concepts, a list of important terms, and basic Git commands using human language. We won't get stuck in rigid technical definitions from textbooks. Instead, we'll explore Git like a story. Get your coffee ready, let's start this Git learning journey!
What is Git Actually?
In simple terms, Git is a Version Control System (VCS) or version control system. Let's use the analogy of a time machine or a checkpoint system in a video game.
When you are playing game and are about to face a difficult boss, what do you do? You will definitely save (save) your game at that point. If it turns out that your character loses, you don't need to start the game again. You just need to reload (load) your last save data.
Git works exactly like that for your code. Every time you complete a feature, a page landing page, or even just fix a small bug in your database configuration, you can create checkpoint. If one day your new code suddenly damages a system that was previously running normally, you don't need to panic by pressing the Ctrl+Z hundreds of times or remembering which line you deleted. You can simply ask Git to revert your code to the previous checkpoint which is still safe.
Apart from being a "time machine", Git is also the best collaboration tool in the technology industry. This system allows multiple developers to work in the same project folder, editing the same files, at the same time, without overwriting each other's work.
Git vs GitHub: Don't Get This Confused!
Before going further into the technical part, we must clear up one of the most common misconceptions experienced by beginners: Git and GitHub are not the same. Thinking of them as the same is like equating "Camera" with "Instagram".
-
Git is the software or engine that drives it. It is a program that you install on your laptop or computer to track file changes locally (without needing the internet).
-
GitHub (or alternatives such as GitLab and Bitbucket) is an internet-based hosting service. Think of GitHub as a social media or Google Drive specifically for code that uses Git technology.
So, you can use Git locally on your laptop without ever touching GitHub at all. However, if you want to show off your portfolio, store backups in the cloud, or collaborate with your team remote, you will require GitHub.
Basic Concepts and Required Vocabulary in the Git World
Many people give up learning Git because they just memorize the commands without understanding the "way of thinking" of the system. In the Git ecosystem, you have to understand that your code is actually being moved around to different stages or rooms.
The Three Main Workspaces (The Three Trees)
The file movement architecture within Git is divided into three main areas:
-
Working Directory (Your Work Desk): This is the project folder that you are currently opening on your computer. For example, you are editing the design file
page.tsxor setting colors intailwind.config.js. All the files that you physically see and are currently typing the code for are located here. Git sees these files, but has not officially logged the changes to permanent history. -
Staging Area (Waiting Room / Shopping Cart): Imagine you are in a supermarket. Working Directory is a shelf of items. When you pick up an item and put it in your shopping cart, the item is not officially yours. This bucket is called the Staging Area. You might be editing 10 files, but you only want to save changes to 2 files first. So, you just register the 2 files in the Staging Area.
-
Git Directory / Repository (Permanent History Repository): This is the cashier's desk. When you are sure about the items in your basket (Staging Area), you pay for them and record them on the shopping receipt. At this stage, your code changes are officially entered into the Git database permanently.
Important Terms
To be able to communicate with fellow developers, you must know this standard vocabulary. Here is a list of important terms you will encounter every day:
-
Repository (repo): The project folder tracked by Git, indicated by the presence of a hidden folder named
.git. If this folder is deleted, your project will return to a regular folder without tracking history. -
Commit: Snapshot of the entire file at a time, with an explanatory message. This is a real form of the "checkpoint" or "shopping receipt" analogy that we discussed previously.
-
Branch: A development branch separate from the mainline. This allows you to create "parallel worlds" or multiverses from your code to test new features without breaking the main code.
-
HEAD: Pointer (such as bookmark or bookmark) to commit or branch that is currently active. Where HEAD is, that's where your computer is looking at that version of the code.
-
-
Clone: Copies the repository from remote (internet) to local (your computer). Usually this is done the first time you take part in an ongoing project.
-
Fork: Copying someone else's repository to our own account (such as a GitHub account). This is often used in the open-source world if you want to freely modify someone else's project without asking permission directly from the original owner.
-
Merge: Merges two branches into one. For example, merging the branch where you created a new feature into the stable main branch.
-
Conflict: An annoying situation where Git cannot automatically merge changes. This usually happens because you and your teammates edited exactly the same lines of code in the same file, and Git got confused about which one to keep.
Git Interlocking Basic Commands Tutorial
Now, let's get to the practical part. We will simulate real workflows used by software engineers.
git init (Building the Foundation)
Let's say you just created a folder called dew-code-app for a new project. Open the Terminal or Command Prompt application, navigate to the folder, then type:
git init
This magic command will turn your regular folder into a Repository. From this moment on, Git is watching that folder.
git status (Checking Current State)
This is a CCTV command. You will use it dozens of times a day.
git status
This command will tell you what files were newly created, what files were recently edited, and whether they are still in the Working Directory (marked in red) or already in Staging Area (marked in green).
git add (Add to Cart)
Let's say you finished creating the layoutframe. You want to prepare the files for saving.
To add one specific file:
git add layout.tsx
Or, if you feel that all the files you changed today are correct and you want to put them all in the basket at once:
git add .
(The dot means "insert all existing changes in this folder").
git commit (Creating Checkpoint)
After the file enters the Staging Area, it's time to save it permanently:
git commit -m "create initial layout and navigation structure"
The letters -m stand for message. Always write descriptive messages. Bad commit messages (such as "update", "fix bug", or "asdffdsa") are the biggest enemy of developers.
git log (Viewing History)
Want to see past history?
git log
This command displays a long list of who did commit, when, and what the message was. For a neater appearance, you can type git log --oneline.
git branch & git checkout (Working in Another Dimension)
In the professional world, you are prohibited from writing new features directly in the main branch (usually named main or master). You have to create a new branch. For example, you are working on an application and want to focus on creating a UKT payment feature:
git branch ukt-payment-features
The branch has been created, but you are not there yet. To move to a new branch dimension, use:
git checkout ukt-payment-features
Now, you're free to mess around with the code in this branch. If it is badly damaged, the main branch will remain pure and clean.
git merge (Putting Back Together)
If your payments feature is complete and tested successfully, you should merge it into the main branch.
First, go back to the main branch:
git checkout main
Then, drag and merge the feature branch into main:
git merge ukt-payment-features
Connect to the Outside World: remote, push, and pull
Sejauh ini kodemu masih bersemayam di laptop lokal. Jika ingin mencadangkannya ke GitHub:
-
Hubungkan ke Remote: (kamu butuh link repo dari GitHub terlebih dahulu)
Bashgit remote add origin https://github.com/username/embun-code-app.git -
Kirim ke Internet (Push):
Bashgit push -u origin main -
Ambil dari Internet (Pull): Jika besoknya kamu menggunakan laptop lain, atau rekan timmu baru saja mengunggah fitur baru ke GitHub, kamu perlu menyinkronkan laptop lokalmu dengan perintah:
Bashgit pull origin main
Menghadapi "Merge Conflict": Mimpi Buruk Pemula
Dalam kamus Git, seperti yang dijelaskan di bagian istilah, Conflict adalah situasi di mana Git mengangkat tangan karena kebingungan.
Bayangkan kamu mengubah baris ke-15 di file .env untuk mengatur konfigurasi database ke server A. Di saat yang sama, teman satu timmu juga mengedit baris ke-15 di file .env yang sama, tapi dia mengarahkannya ke server B. Ketika kalian melakukan merge atau pull, Git akan menghentikan prosesnya. Ia tidak berhak memutuskan konfigurasi mana yang benar.
Jangan panik! Git akan menandai file yang bentrok. Jika dibuka di code editor (seperti VS Code), tampilannya akan menjadi aneh seperti ini:
<<<<<<>>>>>> fitur-database-baru
Penyelesaiannya sangat manusiawi. Kamu hanya perlu berdiskusi dengan tim, putuskan baris mana yang ingin dipakai, hapus teks penanda dari Git (<<<<<<<, =======, >>>>>>>), lalu simpan. Setelah beres, lakukan git add dan git commit untuk meresmikan penyelesaian konflik tersebut.
Praktik Terbaik (Best Practices) Menggunakan Git
Agar sejarah project-mu enak dibaca dan mudah di-maintain, biasakan hal-hal berikut sejak hari pertama:
-
Satu Commit, Satu Logika Logis: Jangan membuat satu commit besar yang berisi 30 file untuk 5 fitur yang berbeda. Pecah-pecah commit-mu. Misalnya: "menambahkan tombol login", lalu commit. "merapikan animasi transisi", lalu commit. Jika suatu saat ada error di animasi transisi, kamu bisa mengembalikan fitur itu tanpa harus mengorbankan fitur tombol login.
-
Jangan Pernah Upload File Rahasia: File seperti
.env(yang berisi password, API Keys, rahasia database) atau folder beban berat sepertinode_modulesatauvendordilarang keras masuk ke Git. Gunakan file bernama.gitignoredan tulis nama file rahasia tersebut di dalamnya agar Git sengaja mengabaikannya. -
Selalu Tarik (Pull) Sebelum Mendorong (Push): Jika bekerja dalam tim, biasakan melakukan
git pulldi awal hari sebelum mulai coding, untuk memastikan kamu bekerja dengan versi kode yang paling mutakhir.
Kesimpulan
Bagi sebagian orang, belajar Git di tahap awal memang terasa seperti belajar bahasa mesin karena harus mengetik perintah di layar terminal yang hitam. Namun percayalah, memahami ekosistem Git (terutama menguasai istilah seperti Repository, Branch, Commit, hingga Merge) adalah investasi skill yang wajib dimiliki.
Dengan menguasai Git, tidak akan ada lagi drama "kode hilang", "salah timpa file teman", atau penamaan folder "project-final-banget-revisi". Alur kerjamu akan menjadi profesional, tertata, dan siap terjun ke dunia industri software engineering. Mulailah dari sekarang, buat sebuah folder kosong, jalankan git init, dan mulailah menulis sejarah kodemu sendiri!

Sigit Wasis Subekti
Software Engineer & Tech Educator
Software Engineer and Tech Educator sharing insights on web development and software architecture.