SYSTEM NOTICE

Auto translation by AI. Be sure, accuracy, nuances and authorial intent may not be fully reflected.
見出し画像

What is "Git"? A gentle, non-scary first step🌿

Good evening, this is Kyon✨

You may have heard the name "Git," but when you look it up, you see black screens with English commands,
and terms like "commit" and "branch"... it's all just jargon.

Honestly, I was a little scared at first too💦

But actually, what Git does is really simple🌸

Today, I'd like to take some time to break it down together in a way that even those with no programming experience can understand😇

To begin with, what does Git actually do for us?

Git is a system that records the "history of changes" to files

For example, have you ever had experiences like these?

  • Thinking, "I really want to go back to yesterday's version"

  • Having someone's changes get deleted during group work

  • Ending up with files like "Report_Final_RealFinal_v3.docx"

With Git, you can return to a past state at any time, and you can see exactly who changed what and when.

It might be close to thinking of it as "a game where you can freely create save points" 🥰

Initial Preparation

Where do you operate Git?

You use Git on a screen where you type in text🤭

The name varies depending on your computer, so let's organize that.

  • Mac: "Terminal" (included by default)

  • Windows: "Command Prompt," "PowerShell," or "Git Bash" which is installed along with Git

They all look similar, using a dark screen where you type in commands.
Since you operate them with the keyboard instead of the mouse, it can be nerve-wracking at first, but once you get used to it, it's actually quite comfortable✨

Installing Git on your computer

First, let's install Git on your computer🌸

For Mac users run the following in your terminal✨

brew install git

For Windows users download and install "Git for Windows"✨

https://git-scm.com/install/windows

To check if it's installed,

git --version

try typing this.
If text like git version 2.xx.x appears, the installation was successful🌸

Next, let's set your name.
This is used to record "who made these changes"🌸

git config --global user.name "あなたの名前"
git config --global user.email "your-email@example.com"

The basic flow of Git ── Just 3 steps

Step 1: Create a "repository"

A repository is asking Git to "record the change history of this folder."
Think of it like preparing a diary🌸

There are generallytwo ways to prepare a repository.

When starting from scratch on your own use this

mkdir my-project
cd my-project
git init
  • mkdir … Create a folder (short for make directory)

  • cd … Move into a folder (short for change directory)

  • git init … Start recording with Git (short for initialize)

When you want to get someone else's project use this

git clone https://github.com/user/repository.git

With clone, you can copy an entire repository✨
In this case, git init is not needed. clone prepares everything for you🤭

Step 2: Record changes

In Git, changes pass throughthree places before they are saved.

A diary Let's use this as an analogy🥰

1. Working Directory (Draft Notebook)
The place where you edit files normally.
The stage where you write whatever comes to mind.

2. Staging Area (Choosing what to finalize)
The stage where you decide, "I'll write this in today's diary."
You can choose just the parts you want to keep, not the whole draft.

3. Repository (Diary Book)
The state where you've written it in pen and the page is finalized.
This becomes your save point.

Specifically, you do it like this🌸

git status

Use status to check which files have changed.

git add ファイル名

Use add to select the files you want to record as "content to finalize."

git commit -m "変更内容のメモ"

Use commit to write to the diary = create a save point✨

The text after -m is a note called a commit message.
It's like the title of a diary entry.
Writing a short note on "what you changed and why" will really help you later.

Step 3: Looking back at history

git log

Use log to display a list of past save points.

git diff

Use diff to check changes that haven't been recorded yet🌸

"Branch"── A system for safe experimentation

Branch is a feature that lets you try out different work while keeping the current state intact😇

In game terms, it's like trying out a different route in a new save slot while keeping your main save data as is🌸
If it goes well, you merge it into the main one; if not, you just delete that slot🎮

git switch -c feature/new-function

Create a new branch and switch to it (switch = change, -c = create = create new).

💡 For those using older versions of Git
If you can't use git switch, you can type git checkout -b feature/new-function instead to achieve the same thing🌸

git switch main

Return to the original branch (main).

git merge feature/new-function

Use merge to combine the contents of the branch✨

"Remote Repository"── Connecting with others

Up until now, we have only been talking about things inside your own computer.

Remote repositoriesallow you to store files on the internet and collaborate with others🥰

It's like cloud saves for games.
Even if your computer breaks, your data remains, and you can access it from other locations.

A representative service isGitHub🌸

Once you create a repository on GitHub, first youregister it as a connection destinationon your computer.

git remote add origin https://github.com/あなたのユーザー名/リポジトリ名.git

With this, your computer will remember the remote repository under the name "origin".
(If you started with clone, this step is done automatically, so it is unnecessary😇)

After that,

git push origin main

Use push to send your changes to the remote.

git pull origin main

Use pull to bring in changes from others.

Send with push, receive with pull.
With these two, you can take your first step into team development✨

Conclusion

Thank you so much for reading this far🥰

First,init → add → commit,
if you can just remember this three-step flow, you can consider yourself a Git user✨

Once you get used to it, try branches,
and then try linking with GitHub...
Please take it one step at a time, at your own pace🌸

I am still in the middle of learning it myself, though🤭

If you felt even a little bit of "I see," I would be very happy💕

Let's learn it together, little by little😇


#Git #GitIntroduction #ProgrammingBeginner #GitHub #VersionControl

📱SNS

I'm also on social media, so please follow me!

🔵X

⚫Threads


いいなと思ったら応援しよう!

きょん(るびぃ)🌸コードとスキルの探求者 よろしければ応援お願いします🌸いただいたチップはクリエイターとしての活動費に使わせていただきます✨