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?

More than 3 years have passed since last update.

【あるある】「やべ、コミットから抜けてるファイルがあった」の解決法

Last updated at Posted at 2021-12-29

目的

gitでコミットして、そのまま作業を進めようと思った時に、「あ、この修正・追加もさっきのコミットに入れておけばよかったーー!!」ということがよく起きる。この時にすぐにその修正を最新のコミットに入れたいと考えた。

結論

記事にしていいのかと言うくらいすごい簡単だった。

① 追加したいファイルをステージングし、
git commit --amend --no-editで前回のコミットにステージングされているファイルを適用させる。

詳細

追加したいファイルをステージング

前回のコミットに追加したいファイルをステージングする

$ git add test.py

前回のコミットにステージングされているファイルを適用

$ git commit --amend --no-edit

参考

[Git] 追加の変更を最新のコミットに追加する

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?