0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Gitについて

Last updated at Posted at 2025-10-25

背景

新しく参画させていただいたプロジェクトでgitコマンドをよく使っています。基本的な操作しか知らなかったので、かなり苦労しました。後で確認できるように箇条書きでメモしておきます。

学んだこと

・git fetch originとgit rebase origin/mainのoriginは意味が違います。
→前者のoriginはリモートのリポジトリを指します。つまり、originという名前で登録されているリモートURLです。通常、originはgit cloneしたときに自動で登録されます。
例:

git remote -v

origin  https://github.com/user/repo.git (fetch)
origin  https://github.com/user/repo.git (push)

git fetch originはリモートorigin全体から、ブランチ情報をローカルに更新する。結果として、origin/main・origin/developなどのローカルにあるリモート追跡ブランチが更新されます。

→後者のoriginはリモート全体ではなく、リモートの中の特定ブランチ(main)を追跡している “リモート追跡ブランチ” を指します。origin/mainはローカルに保持しています。リモートのブランチの最新状態(のコピー)です。git fetch origin を行った時に更新されます。「origin/main」は、直近でフェッチした時点のリモートmainブランチを指します。

・git mergeとrebaseの違いは簡単に言いますと、コミット履歴が枝分かれするかどうかということです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?