[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”

[Low cost] Wasabi object storage construction and operation service

[Low cost] Wasabi object storage construction and operation service

[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 “beSIM”

[Compatible with over 200 countries] Global eSIM “beSIM”

[Compatible with Chinese corporations] Chinese cloud / server construction, operation and maintenance

[Compatible with Chinese corporations] Chinese cloud / server construction, operation and maintenance

[YouTube] Beyond official channel “Biyomaru Channel”

[YouTube] Beyond official channel “Biyomaru Channel”

GitをVScodeで操作しよう!

はじめまして、システム開発部の長門です!
今回はバージョン管理システム「Git(ギット)」をvscodeから操作する方法を解説していきます。

Gitの基本的な操作6つを以下の順に解説していきます。

・ブランチの切り替え&作成
・コミット&プッシュ
・プル
・マージ(競合解消)

ブランチの切り替え&作成

画面左下にブランチ名が書いている欄があります。

そこをクリックすると上部にダイアログが表示され、ブランチの作成と切り替えが出来ます。
「新しい分岐を作成...」でカレントブランチの子ブランチを作成出来ます。

名前を入力し、Enterで完成!

左下の欄を見ますと、先ほど作成したブランチに切り替わっていることが確認できます。
まだこの段階では、ローカルブランチのみの作成なので、横の発行ボタンをクリックしてリモートブランチを作成しましょう。

コミット&プッシュ

続いてコミットとプッシュをしていきましょう。
ファイルを少し編集します。すると、サイドバーで①と表示しているタブがあります。
これは編集されたファイルが1つありますよ、と表示してくれています。
タブに移動し、編集したファイル名の横にある+をクリックします。

すると、「ステージされている変更」に移動することが出来ます。
この「ステージされている変更」に移動しているファイルのみコミットすることが出来るので、
コミットするもの、まだしないものを区別することが出来ます。

テキストボックスにコメントを入れ、チェックをクリックすることでコミットが完了します。

最後にプルをしましょう。
左下の1↑となっている部分をクリックするだけでプルが完了します。

プル

プルも先ほどのプッシュと同様に
1↓となっている部分をクリックするだけです。
リモートブランチに変更や追記がされたファイルがあれば、1以上の数字がここに表示されますので細目にチェックしましょう。

マージ(競合解消)

最後にマージと競合解消を行っていきましょう。
左のタブに移動して、「・・・」の部分をクリックしましょう。
ここからでもコミットやプル、プッシュなどの操作が可能です。
今回は「ブランチ」から「ブランチをマージ...」を選択しましょう。

すると、ダイアログが表示されるのでマージしたいブランチを選択します。

ブランチ選択後、マージが自動的に行われます。
競合が発生していると、このように現在の変更(違うブランチの変更)と入力側の変更(マージブランチ側の変更)と色分けがされます。
競合が発生している変更点の上に
「現在の変更を取り込む|入力側の変更を取り込む|両方の変更を取り込む|変更の比較」
と表示されおり、選択することが出来ます。
今回は「両方の変更を取り込む」を選択します。

変更が適用され無事に競合を解消出来ました。
コミットしてプルすれば、リモートブランチへの反映も完了です。

まとめ

Ctrl+Alt+@でコンソールを開くことが出来るので、gitコマンドで今までの操作も可能です。
ですが、VScodeで行うgitの管理は直感的で分かりやすくスムーズに行えますので、ぜひ試してみて下さい。

最後に

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

この記事がお役に立てば【 いいね 】のご協力をお願いいたします!
1
読み込み中...
1 票, 平均: 1.00 / 11
11,290
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

Masaki Nagato

Joined as a new graduate in April 2020.
My name is Nagato and I belong to the System Development Department. He mainly develops web systems and game APIs using PHP.
Qualification: PHP7 engineer certification beginner level