Skip to content

Instantly share code, notes, and snippets.

@cesarkawakami
Created October 26, 2017 18:56
Show Gist options
  • Save cesarkawakami/9b7602fbde9cd4175401d41a8bd7a56d to your computer and use it in GitHub Desktop.
Save cesarkawakami/9b7602fbde9cd4175401d41a8bd7a56d to your computer and use it in GitHub Desktop.
$ git init .
Initialized empty Git repository in /home/kawakami/temp/test/.git/
$ git commit -m 'initial empty commit' --allow-empty
[master (root-commit) 6d50178] initial empty commit
$ git commit -m 'another empty commit' --allow-empty
[master 9f80fea] another empty commit
$ git commit -m 'yet another empty commit' --allow-empty
[master ed5c03b] yet another empty commit
$ git commit -m 'yet another empty commit' --allow-empty
[master ed5c03b] yet another empty commit
$ git lg
* ed5c03b - (HEAD -> master) yet another empty commit (1 second ago) <Cesar Kawakami>
* 9f80fea - another empty commit (14 seconds ago) <Cesar Kawakami>
* 6d50178 - initial empty commit (24 seconds ago) <Cesar Kawakami>
$ git lg --stat
* ed5c03b - (HEAD -> master) yet another empty commit (7 seconds ago) <Cesar Kawakami>
* 9f80fea - another empty commit (20 seconds ago) <Cesar Kawakami>
* 6d50178 - initial empty commit (30 seconds ago) <Cesar Kawakami>
$ git rebase -i 6d50178 --keep-empty
Stopped at 4e554cd... another empty commit
You can amend the commit now, with
git commit --amend
Once you are satisfied with your changes, run
git rebase --continue
$ git commit --amend --allow-empty
[detached HEAD 1701704] another empty commit, now edited
Date: Thu Oct 26 11:50:55 2017 -0700
$ git rebase --continue
Successfully rebased and updated refs/heads/master.
$ git lg
* 79939d4 - (HEAD -> master) yet another empty commit (3 seconds ago) <Cesar Kawakami>
* 1701704 - another empty commit, now edited (13 seconds ago) <Cesar Kawakami>
* 6d50178 - initial empty commit (4 minutes ago) <Cesar Kawakami>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment