Created
September 30, 2009 11:44
-
-
Save timcharper/198039 to your computer and use it in GitHub Desktop.
how to create an empty commit under an existing initial commit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rm -rf .git | |
$ git init | |
Initialized empty Git repository in /Users/timcharper/project/.git/ | |
$ date > file.txt | |
$ git add file.txt | |
$ git commit -m "initial commit" | |
[master (root-commit) 399a71c] initial commit | |
1 files changed, 1 insertions(+), 0 deletions(-) | |
create mode 100644 file.txt | |
master$ | |
master$ git symbolic-ref HEAD refs/heads/newbranch | |
$ git rm --cached * | |
rm 'file.txt' | |
$ git status | |
# On branch newbranch | |
# | |
# Initial commit | |
# | |
# Changes to be committed: | |
# (use "git rm --cached <file>..." to unstage) | |
# | |
# new file: file.txt | |
# | |
$ git rm --cached * | |
rm 'file.txt' | |
$ git status | |
# On branch newbranch | |
# | |
# Initial commit | |
# | |
# Untracked files: | |
# (use "git add <file>..." to include in what will be committed) | |
# | |
# file.txt | |
nothing added to commit but untracked files present (use "git add" to track) | |
$ git commit -m "empty initial commit" --allow-empty | |
[newbranch (root-commit) d3e31fe] empty initial commit | |
newbranch$ git checkout master | |
error: Untracked working tree file 'file.txt' would be overwritten by merge. | |
newbranch$ git clean -f | |
Removing file.txt | |
newbranch$ git checkout master | |
Switched to branch 'master' | |
master$ git rebase newbranch | |
First, rewinding head to replay your work on top of it... | |
Applying: initial commit | |
master$ git log | |
commit 814c310abf3be91c8e137db3ca83e294a0d9099b | |
Author: Tim Harper <[email protected]> | |
Date: Wed Sep 30 05:39:25 2009 -0600 | |
initial commit | |
commit d3e31fed9490a5dc3e095975b4bfa486d1fc2679 | |
Author: Tim Harper <[email protected]> | |
Date: Wed Sep 30 05:42:18 2009 -0600 | |
empty initial commit | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment