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

ローカルgit操作方法(修正版)

【バージョン確認】

git --version

【作業者名登録】(globalは1回だけ)

git config --global user.name "●"
git config --global user.email "●@●"
  • 登録削除
    git config --global --unset ●

  • 確認
    git config --global --list

【リポジトリ作成】

git init

【状態確認】

git status

【ステージングエリア】

■追加

git add .

■戻す(修正)

  • 【ログ確認】
    git log --graph --all --oneline

  • 【戻す】(新しい方法)
    git restore --staged ●

【コミット】

git commit -m "●"

【ログ確認】

git log --graph --all --oneline

【比較】

git diff

【削除】

  • ファイル削除とステージングを行う。そのあとにcommitが必要
    git rm

  • 手動で削除した場合すでに追跡されているファイルを外す
    git rm --cached ●

【ファイル名変更】commitが必要

git mv ● ▲

【変更の詳細表示】(エディタ状態になる)

git show

【ブランチ】(修正)

  • 一覧表示
    git branch

  • ●作成と移動を同時に行う(新しい方法)
    git switch -c ●

  • 現在の場所にマージする
    git merge ●

  • ブランチを削除
    git branch -d ●

【ファイル復元】(新機能)

  • ワーキングディレクトリのファイルを復元
    git restore全体をcommit前に戻す
    git restore ●指定ファイルだけ戻す

  • 特定のコミットからファイル全体を復元
    git restore --source=HEAD~1 .1つ前
    git restore --source=HEAD~2 .2つ前

【リポジトリ削除】

.gitディレクトリを削除する

【バージョンを消す】(危険⚠️)

  • ログを確認
    git log --graph --all --oneline

  • 戻すバージョンのIDを指定(履歴が消える!
    git reset --hard <commitID>

⚠️ 注意: reset --hard は履歴を完全に削除します!
安全にファイルだけ戻したい場合は git restore を使いましょう。

LFS(Large File Storage)

1.GIt LFSをインストール(git単位)
git lfs install

2.拡張子を指定

git lfs track "*.png"

書式
git lfs track "*.拡張子"

3.通常通りadd commit する。

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?