VibeKoding / Level 2 ยท DeveloperLevel 2 ยท Developer / Alur Kerja Git & GitHub: Mesin Waktu KodeAlur Kerja Git & GitHub: Mesin Waktu Kode
VK

Alur Kerja Git & GitHub: Mesin Waktu KodeAlur Kerja Git & GitHub: Mesin Waktu Kode

๐Ÿ“š Level 2 ยท DeveloperLevel 2 ยท Developer ๐ŸŒ Dual Bahasa (ID / EN) โšก VibeKoding Native

Modul praktis Level 2 VibeKoding: Alur Kerja Git & GitHub: Mesin Waktu Kode.Modul praktis Level 2 VibeKoding: Alur Kerja Git & GitHub: Mesin Waktu Kode.

In previous chapters, we learned how to use web-based vibe coding tools to write code. Each conversation could generate a new version of the code. But that raises an important question: if we want to return to an earlier version, is there a convenient way to do it? Is there a tool that can record our code at different stages so we can switch between versions freely?In previous chapters, we learned how to use web-based vibe coding tools to write code. Each conversation could generate a new version of the code. But that raises an important question: if we want to return to an earlier version, is there a convenient way to do it? Is there a tool that can record our code at different stages so we can switch between versions freely?

That is exactly why version control software exists. In this chapter, we will introduce the most famous version control system, Git, and the most popular code hosting platform, GitHub. You will learn how to manage code with Git, how to download code from GitHub, how to upload your own work, and how to collaborate with others on larger projects.That is exactly why version control software exists. In this chapter, we will introduce the most famous version control system, Git, and the most popular code hosting platform, GitHub. You will learn how to manage code with Git, how to download code from GitHub, how to upload your own work, and how to collaborate with others on larger projects.

Whether you are tracking changes in a personal project, synchronizing code with teammates, or contributing to open source, Git and GitHub are essential tools for modern developers. Once you understand them, you can manage code more confidently, create checkpoints whenever needed, move between different stages of a project, and keep every change traceable.Whether you are tracking changes in a personal project, synchronizing code with teammates, or contributing to open source, Git and GitHub are essential tools for modern developers. Once you understand them, you can manage code more confidently, create checkpoints whenever needed, move between different stages of a project, and keep every change traceable.

> ๐Ÿ’ก Prerequisites> ๐Ÿ’ก Prerequisites

>>

> Before learning Git, it helps to understand:> Before learning Git, it helps to understand:

> - [What Is the Terminal / Command Line](/en/appendix/2-development-tools/command-line-shell)> - [What Is the Terminal / Command Line](/en/appendix/2-development-tools/command-line-shell)

> - [What Is Git](/en/appendix/2-development-tools/git-version-control)> - [What Is Git](/en/appendix/2-development-tools/git-version-control)

>>

> This chapter focuses on the GitHub workflow and hands-on usage, while the links above cover the core fundamentals.> This chapter focuses on the GitHub workflow and hands-on usage, while the links above cover the core fundamentals.

Before using Git, make sure you already understand the basics of the command line and Git itself. This chapter assumes you have that foundation and moves directly into installation, configuration, and practical GitHub collaboration.Before using Git, make sure you already understand the basics of the command line and Git itself. This chapter assumes you have that foundation and moves directly into installation, configuration, and practical GitHub collaboration.

How to install GitHow to install Git

We will briefly walk through installation on the three major operating-system families.We will briefly walk through installation on the three major operating-system families.

WindowsWindows

  1. Go to the [official Git download page](https://git-scm.com/download/win) and download the installer that matches your system. In most cases, the x64 installer is recommended.Go to the [official Git download page](https://git-scm.com/download/win) and download the installer that matches your system. In most cases, the x64 installer is recommended.
  2. Double-click the installer and follow the setup wizard:Double-click the installer and follow the setup wizard:
  3. ๐Ÿ–ผ๏ธ Alur Kerja Git & GitHub: Mesin Waktu KodeAlur Kerja Git & GitHub: Mesin Waktu Kode

    1. In most cases, keeping the default settings is fine. If you customize them, pay attention to:In most cases, keeping the default settings is fine. If you customize them, pay attention to:
    2. Default editor: you can keep Vim, or choose Visual Studio Code if you already have it installed.Default editor: you can keep Vim, or choose Visual Studio Code if you already have it installed.
    3. ๐Ÿ–ผ๏ธ Alur Kerja Git & GitHub: Mesin Waktu KodeAlur Kerja Git & GitHub: Mesin Waktu Kode

      • How Git is used from the command line: a practical default is the option that adds Git to the command line and third-party software without overcomplicating the system setup.How Git is used from the command line: a practical default is the option that adds Git to the command line and third-party software without overcomplicating the system setup.

      ๐Ÿ–ผ๏ธ Alur Kerja Git & GitHub: Mesin Waktu KodeAlur Kerja Git & GitHub: Mesin Waktu Kode

      1. After installation, right-click on the desktop. If you see Git Bash Here, the installation succeeded.After installation, right-click on the desktop. If you see Git Bash Here, the installation succeeded.
      2. ๐Ÿ–ผ๏ธ Alur Kerja Git & GitHub: Mesin Waktu KodeAlur Kerja Git & GitHub: Mesin Waktu Kode

        macOSmacOS

        On macOS, you can first run git --version in Terminal to check whether Git is already installed. If it is not, macOS often prompts you to install the developer tools automatically.On macOS, you can first run git --version in Terminal to check whether Git is already installed. If it is not, macOS often prompts you to install the developer tools automatically.

        1. Method 1: install with HomebrewMethod 1: install with Homebrew
        2. If you have [Homebrew](https://brew.sh/), open Terminal and run brew install gitIf you have [Homebrew](https://brew.sh/), open Terminal and run brew install git

          1. Method 2: install Xcode toolsMethod 2: install Xcode tools
          2. You can also install Xcode or the Xcode Command Line Tools from Apple. Git is included as part of that toolchain.You can also install Xcode or the Xcode Command Line Tools from Apple. Git is included as part of that toolchain.

            LinuxLinux

            Most Linux distributions install Git through the system package manager:Most Linux distributions install Git through the system package manager:

            • Ubuntu / Debian:Ubuntu / Debian:
            bash
            sudo apt update sudo apt install git
            
            • CentOS / RHEL:CentOS / RHEL:
            bash
            sudo yum install git
            

            To verify the installation, run git --version. If a version number appears, Git is ready.To verify the installation, run git --version. If a version number appears, Git is ready.

            Initialize Git identityInitialize Git identity

            After installing Git, the first thing you should do is configure your user information. Run the following commands in the terminal and replace the values with your own:After installing Git, the first thing you should do is configure your user information. Run the following commands in the terminal and replace the values with your own:

            bash
            # Set the global username shown in commit history git config --global user.name "Your Name" # Set the global email, ideally the same one you use on GitHub git config --global user.email "your.email@example.com"
            

            Git writes this information into every commit as the author identity. When you inspect the version history, you can clearly see who changed what and communicate more easily in collaborative projects.Git writes this information into every commit as the author identity. When you inspect the version history, you can clearly see who changed what and communicate more easily in collaborative projects.

            You can confirm the configuration with:You can confirm the configuration with:

            bash
            git config --list
            

            GitHub is a code hosting platform built on top of Git. It provides remote storage for Git repositories and adds collaboration tools such as Issues, Pull Requests, and Projects. In simple terms, Git is the local version-control tool, while GitHub is the remote code warehouse and collaboration layer.GitHub is a code hosting platform built on top of Git. It provides remote storage for Git repositories and adds collaboration tools such as Issues, Pull Requests, and Projects. In simple terms, Git is the local version-control tool, while GitHub is the remote code warehouse and collaboration layer.

            GitHub is also the world's largest and most influential open-source community. The idea of open source is that anyone can download and run the source code of a project. That allows people around the world to inspect each other's work, improve it, and build new things on top of it.GitHub is also the world's largest and most influential open-source community. The idea of open source is that anyone can download and run the source code of a project. That allows people around the world to inspect each other's work, improve it, and build new things on top of it.

            ๐Ÿ–ผ๏ธ Alur Kerja Git & GitHub: Mesin Waktu KodeAlur Kerja Git & GitHub: Mesin Waktu Kode

            Large companies often open-source tools and tutorials on GitHub as part of their technical strategy. In the GitHub ecosystem, the number of stars a project receives is one of the most visible indicators of trust and influence.Large companies often open-source tools and tutorials on GitHub as part of their technical strategy. In the GitHub ecosystem, the number of stars a project receives is one of the most visible indicators of trust and influence.

            ๐Ÿ–ผ๏ธ Alur Kerja Git & GitHub: Mesin Waktu KodeAlur Kerja Git & GitHub: Mesin Waktu Kode

            In this course, many supporting resources and assignments are also published in GitHub repositories. By learning to upload your own work there, you gradually build the workflow you will use for real application development later.In this course, many supporting resources and assignments are also published in GitHub repositories. By learning to upload your own work there, you gradually build the workflow you will use for real application development later.

            Create a GitHub accountCreate a GitHub account

            1. Visit [GitHub](https://github.com/) and click Sign up in the top-right corner.Visit [GitHub](https://github.com/) and click Sign up in the top-right corner.
            2. ๐Ÿ–ผ๏ธ Alur Kerja Git & GitHub: Mesin Waktu KodeAlur Kerja Git & GitHub: Mesin Waktu Kode

              1. Enter your email address, create a password, and complete the verification steps.Enter your email address, create a password, and complete the verification steps.
              2. Confirm your email, and your account is ready.Confirm your email, and your account is ready.
              3. Create your first repository on GitHubCreate your first repository on GitHub

                Next, let's create your first repository, often shortened to repo.Next, let's create your first repository, often shortened to repo.

                ๐Ÿ–ผ๏ธ Alur Kerja Git & GitHub: Mesin Waktu KodeAlur Kerja Git & GitHub: Mesin Waktu Kode

                ๐Ÿ–ผ๏ธ Alur Kerja Git & GitHub: Mesin Waktu KodeAlur Kerja Git & GitHub: Mesin Waktu Kode

                When creating a repository, the main fields mean:When creating a repository, the main fields mean:

                1. Repository name: the public-facing name of the repositoryRepository name: the public-facing name of the repository
                2. Description: a short explanation of what the repository is forDescription: a short explanation of what the repository is for
                3. Visibility:Visibility:
                4. Private: only you and people you explicitly invite can see itPrivate: only you and people you explicitly invite can see it
                5. Public: anyone can see itPublic: anyone can see it
                6. README: it is good practice to add a README. Think of it as the repository's introduction and usage guide.README: it is good practice to add a README. Think of it as the repository's introduction and usage guide.
                7. .gitignore and license:.gitignore and license:
                8. .gitignore tells Git which files or folders should not be tracked, such as temporary files, dependency folders, or local secrets..gitignore tells Git which files or folders should not be tracked, such as temporary files, dependency folders, or local secrets.
                9. license determines how others are allowed to use your open-source code.license determines how others are allowed to use your open-source code.
                10. For your first repository, it is reasonable to check Add README, set the visibility to Private, and fill in a name and description you like. Then click Create repository.For your first repository, it is reasonable to check Add README, set the visibility to Private, and fill in a name and description you like. Then click Create repository.

                  ๐Ÿ–ผ๏ธ Alur Kerja Git & GitHub: Mesin Waktu KodeAlur Kerja Git & GitHub: Mesin Waktu Kode

                  You will now have a clean repository, ready for your files.You will now have a clean repository, ready for your files.

                  ๐Ÿ–ผ๏ธ Alur Kerja Git & GitHub: Mesin Waktu KodeAlur Kerja Git & GitHub: Mesin Waktu Kode

                  To download a repository, you use git clone, which requires the repository URL. You can find that by clicking the green Code button. GitHub usually shows both HTTPS and SSH options.To download a repository, you use git clone, which requires the repository URL. You can find that by clicking the green Code button. GitHub usually shows both HTTPS and SSH options.

                  ๐Ÿ–ผ๏ธ Alur Kerja Git & GitHub: Mesin Waktu KodeAlur Kerja Git & GitHub: Mesin Waktu Kode

                  In general, HTTPS is fine for temporary downloads or quick testing, but for your own daily development workflow, SSH is usually the better experience.In general, HTTPS is fine for temporary downloads or quick testing, but for your own daily development workflow, SSH is usually the better experience.

                  Bind local SSH to GitHubBind local SSH to GitHub

                  In GitHub, "binding SSH" means connecting your local machine's SSH public key to your GitHub account so GitHub can recognize your device through the SSH protocol. Once set up, you can clone, pull, and push securely without re-entering passwords every time.In GitHub, "binding SSH" means connecting your local machine's SSH public key to your GitHub account so GitHub can recognize your device through the SSH protocol. Once set up, you can clone, pull, and push securely without re-entering passwords every time.

                  In plain language: it is like giving your device a special access card for GitHub.In plain language: it is like giving your device a special access card for GitHub.

                  > ๐Ÿ’ก What is SSH?> ๐Ÿ’ก What is SSH?

                  Why use SSH authentication?Why use SSH authentication?

                  GitHub supports two major protocols for repository operations:GitHub supports two major protocols for repository operations:

                  • HTTPS: usually requires a password or Personal Access Token for pushesHTTPS: usually requires a password or Personal Access Token for pushes
                  • SSH: uses a key pair, so you do not need to repeat authentication constantlySSH: uses a key pair, so you do not need to repeat authentication constantly

                  SSH binding is the prerequisite for using GitHub with SSH. You must upload your local SSH public key to GitHub so GitHub can verify your machine.SSH binding is the prerequisite for using GitHub with SSH. You must upload your local SSH public key to GitHub so GitHub can verify your machine.

                  The core logic: SSH key pairsThe core logic: SSH key pairs

                  SSH authentication depends on a key pair:SSH authentication depends on a key pair:

                  1. Private key: stored on your local machine, never sharedPrivate key: stored on your local machine, never shared
                  2. Public key: uploaded to GitHubPublic key: uploaded to GitHub
                  3. When you perform a Git operation over SSH:When you perform a Git operation over SSH:

                    • Your machine signs the request with the private keyYour machine signs the request with the private key
                    • GitHub checks it against the public key you uploadedGitHub checks it against the public key you uploaded
                    • If the match succeeds, the operation is allowedIf the match succeeds, the operation is allowed

                    The actual stepsThe actual steps

                    The core workflow is simple: generate a key pair โ†’ upload the public key to GitHub.The core workflow is simple: generate a key pair โ†’ upload the public key to GitHub.

                    1. Generate an SSH key pair locallyGenerate an SSH key pair locally
                    2. Use Trae to help generate itUse Trae to help generate it
                    3. Prompt:Prompt:

                      Help me create the SSH key needed for GitHub login. My email is your_email@gmail.com. Please return the public key for me to copy.Help me create the SSH key needed for GitHub login. My email is your_email@gmail.com. Please return the public key for me to copy.

                      ๐Ÿ–ผ๏ธ Alur Kerja Git & GitHub: Mesin Waktu KodeAlur Kerja Git & GitHub: Mesin Waktu Kode

                      After entering the prompt, you may still need to press Enter in the terminal pane so the command can continue. Once Trae finishes, it will show you the public key to copy.After entering the prompt, you may still need to press Enter in the terminal pane so the command can continue. Once Trae finishes, it will show you the public key to copy.

                      ๐Ÿ–ผ๏ธ Alur Kerja Git & GitHub: Mesin Waktu KodeAlur Kerja Git & GitHub: Mesin Waktu Kode

                      1. Generate it manuallyGenerate it manually
                      2. Open your terminal and run ssh-keygen -t ed25519 -C "your_email@example.com"Open your terminal and run ssh-keygen -t ed25519 -C "your_email@example.com"

                        Press Enter to accept the defaults unless you want a custom path or passphrase. This creates:Press Enter to accept the defaults unless you want a custom path or passphrase. This creates:

                        • id_ed25519: your private key, which must stay localid_ed25519: your private key, which must stay local
                        • id_ed25519.pub: your public key, which you will upload to GitHubid_ed25519.pub: your public key, which you will upload to GitHub
                        1. Upload the public key to GitHubUpload the public key to GitHub
                        2. This is the binding step itself.This is the binding step itself.

                          1. Copy the public key:Copy the public key:
                          2. On Windows, open C:\Users\\.ssh\id_ed25519.pubOn Windows, open C:\Users\\.ssh\id_ed25519.pub
                          3. On macOS/Linux, run cat ~/.ssh/id_ed25519.pubOn macOS/Linux, run cat ~/.ssh/id_ed25519.pub
                          4. In GitHub, go to your avatar โ†’ Settings โ†’ SSH and GPG keys โ†’ New SSH keyIn GitHub, go to your avatar โ†’ Settings โ†’ SSH and GPG keys โ†’ New SSH key
                          5. ๐Ÿ–ผ๏ธ Alur Kerja Git & GitHub: Mesin Waktu KodeAlur Kerja Git & GitHub: Mesin Waktu Kode

                            1. Enter a title and paste the public key.Enter a title and paste the public key.
                            2. ๐Ÿ–ผ๏ธ Alur Kerja Git & GitHub: Mesin Waktu KodeAlur Kerja Git & GitHub: Mesin Waktu Kode

                              ๐Ÿ–ผ๏ธ Alur Kerja Git & GitHub: Mesin Waktu KodeAlur Kerja Git & GitHub: Mesin Waktu Kode

                              1. Verify the bindingVerify the binding
                              2. Run ssh -T git@github.comRun ssh -T git@github.com

                                If you see a message similar to Hi [your GitHub username]! You've successfully authenticated..., the setup worked.If you see a message similar to Hi [your GitHub username]! You've successfully authenticated..., the setup worked.

                                Important notesImportant notes

                                • If you use multiple devices, create a separate SSH key pair for each one and upload each public key to the same GitHub account.If you use multiple devices, create a separate SSH key pair for each one and upload each public key to the same GitHub account.
                                • Never share your private key.Never share your private key.
                                • After setting up SSH, use SSH repository URLs such as git@github.com:username/repository.git, not HTTPS URLs.After setting up SSH, use SSH repository URLs such as git@github.com:username/repository.git, not HTTPS URLs.
                                • If you cloned a repository over HTTPS earlier, you can switch it with git remote set-url origin If you cloned a repository over HTTPS earlier, you can switch it with git remote set-url origin

                                Now that we have covered Git, GitHub, SSH, and the setup process, you can start asking Trae to help with Git operations.Now that we have covered Git, GitHub, SSH, and the setup process, you can start asking Trae to help with Git operations.

                                git clone: download an existing repositorygit clone: download an existing repository

                                You can directly tell Trae which repository URL you want to clone.You can directly tell Trae which repository URL you want to clone.

                                ๐Ÿ–ผ๏ธ Alur Kerja Git & GitHub: Mesin Waktu KodeAlur Kerja Git & GitHub: Mesin Waktu Kode

                                git pull: fetch the latest remote updatesgit pull: fetch the latest remote updates

                                Before editing, especially in a shared repository, you should pull the latest changes first.Before editing, especially in a shared repository, you should pull the latest changes first.

                                Always include the folder name and its relative or absolute path so you do not pull in the wrong repository by mistake.Always include the folder name and its relative or absolute path so you do not pull in the wrong repository by mistake.

                                Prompt:Prompt:

                                Help me pull this repository AIID-TEST in ./AIID-TEST.Help me pull this repository AIID-TEST in ./AIID-TEST.

                                git commit and git push: stage, save, and upload your updatesgit commit and git push: stage, save, and upload your updates

                                After you modify files locally, you can ask Trae to detect the changes and help you push them to GitHub.After you modify files locally, you can ask Trae to detect the changes and help you push them to GitHub.

                                Prompt:Prompt:

                                I finished. Commit and push to the repository AIID-TEST in ./AIID-TEST.I finished. Commit and push to the repository AIID-TEST in ./AIID-TEST.

                                ๐Ÿ–ผ๏ธ Alur Kerja Git & GitHub: Mesin Waktu KodeAlur Kerja Git & GitHub: Mesin Waktu Kode

                                If the push succeeds, you will be able to see the updated content on GitHub immediately.If the push succeeds, you will be able to see the updated content on GitHub immediately.

                                • Pro Git book: https://git-scm.com/book/en/v2Pro Git book: https://git-scm.com/book/en/v2
                                • GitHub Docs: https://docs.github.com/enGitHub Docs: https://docs.github.com/en