0Pricing
Linux Command Line Mastery · Pelajaran

Dasar-Dasar Git dari Baris Perintah

Pelajari perintah Git penting untuk pengendalian versi, termasuk melakukan commit, membuat cabang, dan menggabungkan cabang.

Dasar-Dasar Git dari Baris Perintah adalah pelajaran Linux Command Line Mastery gratis di CoddyKit. Ini adalah pelajaran 1 dari 4. Kamu bisa membaca pelajaran lengkapnya di bawah secara gratis — lalu praktikkan langsung di browser dengan editor kode bawaan dan tutor AI 24/7. Ini adalah bagian dari jalur belajar Linux Command Line Mastery, dan progresmu tersinkronisasi di web dan aplikasi CoddyKit. Kursus Linux Command Line Mastery mencakup 4 pelajaran total.

Bagian dari pelajaran ini belum diterjemahkan dan ditampilkan dalam bahasa Inggris.

What is Git?

Welcome to Git basics! Git is a powerful Version Control System (VCS). Think of it as a super-smart history book for your code.

It tracks every change you make, letting you revert to older versions, collaborate with others, and manage different features without stepping on toes. It's essential for modern software development!

Starting a Git Project

To begin tracking a project with Git, you first need to initialize a repository. This creates a special .git folder in your project, where Git stores all its tracking information.

Use the git init command in your project's root directory.

mkdir my_project
cd my_project
git init

Staging Your Changes

Before saving your work, Git uses a 'staging area'. This is like a rough draft space where you select which changes you want to include in your next save.

The git add command is used to add files or changes to this staging area.

echo "My first line." > README.md
git add README.md

Saving Your Work (Commit)

Once changes are staged, you 'commit' them. A commit is a snapshot of your project at a specific point in time, with a descriptive message.

Use git commit -m "Your message" to save staged changes to your repository's history.

git commit -m "Initial commit: Added README.md"

Viewing Project History

Git keeps a detailed log of all your commits. You can review this history to see who made what changes and when.

The git log command displays your repository's commit history. The --oneline option provides a concise view.

git log --oneline

Parallel Development with Branches

Branches are a core concept in Git. They allow you to diverge from the main line of development and continue working without affecting the main project.

  • Work on new features.
  • Fix bugs without breaking stable code.
  • Experiment with new ideas.

The main (or master) branch is typically the stable version.

Creating a New Branch

To start a new line of development, you create a new branch. This doesn't move you to the new branch yet; it just creates it.

The git branch <branch-name> command creates a new branch. You can list all branches with just git branch.

git branch feature/login
git branch

Switching Between Branches

After creating a branch, you need to switch to it to start working on that specific line of development. Your files will reflect the state of that branch.

Use git switch <branch-name> to move to an existing branch. It's the modern way to navigate branches.

git switch feature/login
# Now you are on the 'feature/login' branch

Merging Branches

Once you've finished work on a feature branch, you'll want to integrate those changes back into your main development line, usually the main branch.

First, switch to the target branch (e.g., main), then use git merge <source-branch> to bring in the changes.

git switch main
git merge feature/login

Git Workflow Check

You've learned the core steps for managing changes with Git. Let's test your understanding of how to save your work.

Git Basics Summary

Great job! You've learned the fundamental Git commands:

  • git init: To start a new repository.
  • git add: To stage changes for a commit.
  • git commit: To save staged changes to history.
  • git log: To view your project's commit history.
  • git branch: To create and list branches.
  • git switch: To move between branches.
  • git merge: To combine changes from different branches.

These commands form the backbone of managing your code with Git!

Pertanyaan yang Sering Diajukan

Apakah pelajaran “Dasar-Dasar Git dari Baris Perintah” gratis?

Ya — teks lengkap “Dasar-Dasar Git dari Baris Perintah” gratis dibaca di sini di web. Untuk praktiknya secara interaktif (editor kode bawaan dan tutor AI 24/7) dan buka sisa kursus Linux Command Line Mastery, upgrade ke CoddyKit PRO. Kursus Linux Command Line Mastery mencakup 4 pelajaran total.

Apa yang akan aku pelajari di “Dasar-Dasar Git dari Baris Perintah”?

Pelajari perintah Git penting untuk pengendalian versi, termasuk melakukan commit, membuat cabang, dan menggabungkan cabang. Kamu berlatih Linux Command Line Mastery dengan kode praktik yang langsung kamu jalankan di browser, dan tutor AI 24/7 menjawab pertanyaanmu saat kamu mengerjakan pelajaran ini.

Apakah aku perlu pengalaman untuk memulai Linux Command Line Mastery?

Tidak diperlukan pengalaman sebelumnya. Linux Command Line Mastery di CoddyKit dirancang untuk pemula hingga pelajar tingkat lanjut, jadi kamu bisa memulai di sini atau dari awal dan belajar sesuai kecepatan kamu sendiri. Ini adalah pelajaran 1 dari 4.

Berapa lama pelajaran “Dasar-Dasar Git dari Baris Perintah” memakan waktu?

Sebagian besar pelajaran CoddyKit memakan waktu sekitar 5–10 menit. Setiap pelajaran ringkas dan interaktif, jadi kamu membuat kemajuan stabil dan melanjutkan dari tempat kamu tinggalkan di web dan aplikasi.

Bisakah aku menulis dan menjalankan kode dalam pelajaran Linux Command Line Mastery ini?

Ya. Setiap pelajaran Linux Command Line Mastery menyertakan editor kode bawaan, jadi kamu menulis dan menjalankan kode nyata langsung di browser dan mendapatkan umpan balik AI instan — tidak diperlukan penyiapan lokal.

Semua pelajaran dalam kursus ini

  1. Dasar-Dasar Git dari Baris Perintah
  2. Variabel Lingkungan dan Alias
  3. Konfigurasi Shell: `.bashrc`, `.zshrc`, `.profile`
  4. Membuat Cabang dan Menggabungkannya dengan Git dari Baris Perintah
← Kembali ke Linux Command Line Mastery