Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

This article is a Private article. Only a writer and users who know the URL can access it.
Please change open range to public in publish setting if you want to share this article with other users.

Git クライアントを探すのに疲れたから CUI に転向する

0
Posted at

はじめに

Git クライアントを探すのに疲れたから Git for Windows に同梱されている CUI ツール Git Bash に転向しようと思いました。

環境

  • Windows 11 Home
  • Git for Windows 2.54.0

Git Bash の開き方

右クリックメニューから Git Bash を開くと、現在のフォルダをカレントディレクトリとして起動できます。

コマンドの一覧

よく使いそうなものをまとめました。ちなみにペーストは Shift + Ins です。

1. リポジトリのクローンと確認

bash
# リポジトリをクローンする。
git clone https://github.com/XXXX/XXXX

# ディレクトリの移動。
cd XXXX

# 状態を確認する。
git status

2. ブランチの操作

bash
# ブランチの作成を行う。
git branch develop

# ブランチを切り替える。
git switch develop

# ブランチを作成して切り替える。
git switch -c develop

# ブランチの状態を確認する。
git branch

# 全てのブランチを更新日時順で表示する。
git for-each-ref --sort=-committerdate refs/remotes/ --format="%(committerdate:short) %(refname:short)"

# ブランチを削除する。
git branch -D develop

# 現在のブランチ (main) に develop の変更を取り込む。
git switch main
git merge develop

3. 基本の操作

bash
# 変更を確認する。
git diff

# カレントディレクトリ配下の変更をまとめて取り消しする。
git restore .

# カレントディレクトリ配下の変更をまとめてステージングする。
git add .

# コミットする。
git commit -m "message"

# リモートリポジトリにプッシュする。
git push

# リモートリポジトリからプル (fetch + merge) する。
git pull

4. その他

bash
# ログを確認する。
git log --oneline --graph

おわりに

がんばっていきましょう。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?