19
18

More than 5 years have passed since last update.

直前のコミットを取り消して新しいブランチにコミットし直すのに便利なエイリアス

Posted at

「直前のコミットの取り消し」「取り消したコミットのやり直し」に相当するコマンドをすぐ忘れるので uncommitrecommit というエイリアスを作ってある。

[alias]
    co = checkout
    uncommit = reset HEAD^
    recommit = commit -c ORIG_HEAD

直前のコミットを取り消して、現在のブランチから新しいブランチを切り、直前に取り消したコミットメッセージを再利用して改めてコミットするにはこうする:

git uncommit         # コミットを取り消す。変更はワーキングツリーに残る
git co -b new-branch # ブランチを作る
git add .            # 変更をインデックスに追加
git recommit         # 取り消したコミットメッセージを再利用してコミット
19
18
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
19
18