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-12-04

まずは「Git」の基本を勉強する
サル先生のGit入門

ローカルでリポジトリを作成

git init

リモートリポジトリをローカルにcloneする

git clone <https url>/<ssh url>

ファイルやディレクトリをステージに登録

git add <filepattern>

ステージに追加されたファイルをコミット

git commit -m <message>

変更されたファイルの一覧を表示

git status

変更されたファイルの差分を確認

git diff --cached <filepattern>

コミットログ

git log

コミットの詳細を確認

git show <commit-hash>

ファイルやディレクトリ名を変更

git mv <oldfilename> <newfilename>

変更の取り消し

・過去のバージョンに戻す

git checkout <commit-hash> -- <filepattern>

※おすすめ

git restore --source=<commit-hash> <filepattern>

・ステージした変更を取り消す

git restore --staged <filepattern>

・ワーク中の変更を取り消す

git restore <filepattern>
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?