[Osaka/Yokohama] Looking for infrastructure/server side engineers!

[Osaka/Yokohama] Looking for infrastructure/server side engineers!

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Successor to CentOS] AlmaLinux OS server construction/migration service

[Successor to CentOS] AlmaLinux OS server construction/migration service

[For WordPress only] Cloud server “Web Speed”

[For WordPress only] Cloud server “Web Speed”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Reservation system development] EDISONE customization development service

[Reservation system development] EDISONE customization development service

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[Global exclusive service] Beyond's MSP in North America and China

[Global exclusive service] Beyond's MSP in North America and China

[YouTube] Beyond official channel “Biyomaru Channel”

[YouTube] Beyond official channel “Biyomaru Channel”

チーム開発必須!git clone, fetch, pullを解説

git

お疲れ様です!
システム開発部の山田です。

今回は、チーム開発で使うgitコマンドの中で、
使用頻度の高いgit clone, git fetch, git pullの違いについて解説していきます。

git clone

リポジトリのクローンを作成するコマンド。
他の人が作成したプロジェクトのリポジトリを、自分の環境に落とし込むことができる。

````````````````````````````````````````````````````````````````
$ git clone [クローン対象のリポジトリ] [ディレクトリ名(省略可)]
________________________________________________________________

git fetch

リモート追跡ブランチの更新を行うコマンド。
リモートリポジトリから最新情報をローカルリポジトリに持ってくる。

````````````````````````````````````````````````````````````````
$ git fetch [リポジトリ名(省略可)] [ブランチ名(省略可)]
________________________________________________________________

ただし、あくまでもリモート追跡ブランチを更新するものであるため、
現在の作業ブランチに更新内容が反映されるわけではない。

作業内容を反映させたいときは?

現在の作業ブランチに反映させたい場合はmergeを使用する。

````````````````````````````````````````````````````````````````
$ git merge [反映させたいブランチ名]
________________________________________________________________

git pull

上記で説明した`git fetch` を行った後に`git merge origin/main`を行う。

````````````````````````````````````````````````````````````````
$ git pull [リポジトリ名(省略可)] [ブランチ名(省略可)]
________________________________________________________________

各コマンドの使い分け

git clone
プロジェクトの開始時など、自分のローカル環境に何も無い状態の際に使用する。

git fetch

他の人が編集したブランチを取り込むなど、
リモート環境とローカル環境でコンフリクトが起こりそうな場合で、
merge前に確認を取りたい際に使用する。

git pull
main(master)ブランチのような、リモート環境で他ブランチからのプルリクエストのみで更新を行うブランチに対してよく使用する。
(ローカル環境とのコンフリクトが基本的には起こりえないため、差分確認などをする必要がないため。)

まとめ

今回は、チーム開発で使うgitコマンドの中で、使用頻度の高いgit clone, git fetch, git pullの違いについて解説いたしました。
このコマンドを使わずにチーム開発を行うことはまずないので、
今日初めて知った人は、完璧に理解することをお勧めします!

コマンド名 内容
git clone 既に存在するリポジトリのクローンを作成するコマンド
git fetch リモート追跡ブランチの更新を行うコマンド
git merge リモート追跡ブランチを含む、他ブランチの内容を現在のブランチに反映させるコマンド
git pull リモート追跡ブランチの更新を行い、作業ブランチなどに反映させるコマンド

最後に

私が所属するシステム開発のサービスサイト「SEKARAKU Lab(セカラク ラボ)」を開設しました。
ビヨンドは、サーバーの設計・構築から運用までをワンストップでお任せいただけますので、サーバーサイド開発でお困りの方はお気軽にお問い合わせください。
SEKARAKU Lab:https://sekarakulab.beyondjapan.com/

この記事がお役に立てば【 いいね 】のご協力をお願いいたします!
1
読み込み中...
1 票, 平均: 1.00 / 11
9,376
X facebook はてなブックマーク pocket
[2024.6.30 CentOS support ended] CentOS server migration solution

[2024.6.30 CentOS support ended] CentOS server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[Osaka/Yokohama] Actively recruiting infrastructure engineers and server side engineers!

[Osaka/Yokohama] Actively recruiting infrastructure engineers and server side engineers!

The person who wrote this article

About the author

Yuki Yamada

Joined Beyond Co., Ltd. in 2021
My hobbies are karaoke and board
games.My board games can no longer fit on one shelf, so I would like to buy a new shelf, but I am sad because I don't have a place to put a shelf at home.
He has experience in mold design and sales, and has gained a wide variety of experience and has settled into a job as a server-side engineer.
He is currently working on server-side development using PHP and Python.
He also wants to learn a front-end language in the future, and is interested in Next.js, a React-based front-end framework.