git am

git

書き方

git am [-3] <mbox|patch>...

メールで届いたパッチを、元の作者とメッセージのままコミットにします。途中で失敗するとそこで止まるので、--continue・--skip・--abortで決着させます。

よく使うオプション

オプション意味
-3three-way merge when the patch does not apply cleanly
-sadd a Signed-off-by line
--continuego on after you fixed the conflict
--skipdrop this patch and continue the series
--abortundo the whole series
-kkeep the subject line exactly as it is

git am 0001-fix-login.patch

commits the patch, keeping its original author

git am -3 *.patch

applies a whole series, merging where needed

git am --abort

returns to before the series started

取り消しに何通りもあるのが混乱のもとです — ブランチの指す先を動かすのと、打ち消すコミットを積むのは別です。

読み方

  • 角括弧 [ ] は省いてよい部分です。
  • 三点 … は複数並べられるという意味です。
  • オプションは大文字小文字を区別します — -r と -R が別物のコマンドもあります。

よくある質問

Q. git am は何をしますか。

メールで届いたパッチを、元の作者とメッセージのままコミットにします。途中で失敗するとそこで止まるので、--continue・--skip・--abortで決着させます。

Q. どう打ちますか。

git am [-3] <mbox|patch>... — 角括弧は省いてよい部分です。

Q. よく使うオプションはいくつですか。

ここにまとめたのは6個です。全部は man git にあります。このコマンドはgitの仲間です。

関連するコマンド

man ページ: man git-am