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 commit -am の注意点

Posted at

はじめに

Gitを使い始めると、こんなコマンドを見かけることがあります。

git commit -am "メッセージ"

重要な注意点

-a が対象にするファイル

✅ 含まれるもの

状態 説明
modified 既存ファイルの変更 README.md を編集
deleted ファイルの削除 old_file.py を削除

❌ 含まれないもの

状態 説明 対処法
untracked 新規作成したファイル git add が必要

実例: 新規ファイルは含まれない

新しいファイルを作成

touch new_feature.py

ファイルの状態を確認

git status
# Untracked files:
#   new_feature.py

-am でコミット

git commit -am "新機能追加"

❌ new_feature.py はコミットされない!

正しい方法

git add new_feature.py
git commit -m "新機能追加"

新規ファイルは -a では自動追加されません
明示的に git add が必要です。

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?