· 

GitHub: originとmainの違い

これらの違いをなかなか覚えられないので、忘備録的にここに記しておきます。

 

What is the difference between origin and main on git?

 

Great question! Let's break it down simply:


🔹 main

  • main is the name of a branch — usually the default branch in most Git repositories today.

  • It's where the main code lives (like "master" used to be).

  • You can have many branches in a project (e.g. feature-x, dev, bugfix-123), but main is often the primary one.

🔹 origin

  • origin is the nickname for the remote repository — usually the one you cloned from.

  • It's not a branch — it's a reference to the remote location, like GitHub.

  • You can push/pull code between your local repo and origin.


🧠 Example: What does this mean?

bash
git push origin main

This means:

"Push my local main branch to the origin remote (usually GitHub)."


🧪 You can also see what branches and remotes exist:

  • To see branches:

    bash
    git branch
  • To see remotes:

    bash
    git remote -v

 

Let me know if you want a visual of how local vs remote works or how branching fits in!