1
2

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 5 years have passed since last update.

gitのたまに使うコマンド

Posted at

不意にcommit取り消したいとかrebaseでエラーがでるときの解除とか、普段あまり使わなくてコマンドを忘れちゃうので最低限レベルで覚書程度にまとめてみました。

add編

取り消し:git reset

commit編

直前の取り消し:git reset HEAD^
2個前まで取り消し:git reset HEAD^^

■補足
HEAD:最新のコミットに対するハッシュ値の別名

rebase編

取り消し(直後):git reset --hard ORIG_HEAD

[CONFLICTが起きた場合]
解消:git status(確認・修正) ⇒ git addgit rebase --continue
rebase取り消し:git rebase --abort

■補足
ORIG_HEAD:最新の一つ手前のコミットに対するハッシュ値の別名

cherry-pick編

取り消し(直後):git reset --hard ORIG_HEAD

[CONFLICTが起きた場合]
解消:git status(確認・修正) ⇒ git addgit cherry-pick --continue
rebase取り消し:git cherry-pick --abort

番外編

・addとcommitの一括処理をしたい
git commit -am "xxxx"

・コミットしたファイルに、別の修正ファイルを含めたい
git addgit commit --amend

1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?