Command | New files | Changed files | Deleted files |
Alice/> git init --template=""
Initialized empty Git repository in /home/rene/github/github/git-internals/repos/detached-HEAD/Alice/.git/
snap no: 1 | | | |
snap no: 2 | | | |
snap no: 3 | | | |
Alice/> git commit foo -m "add foo"
[master (root-commit) 3fd0cb8] add foo
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 foo
snap no: 4 | | | |
snap no: 5 | | | |
snap no: 6 | | | |
Alice/> git commit bar -m "add bar"
[master 7492cd8] add bar
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 bar
snap no: 7 | | | |
Alice/> git checkout 3fd0cb8
Note: checking out '3fd0cb8'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at 3fd0cb8... add foo
snap no: 8 | | | |
Alice/> ls -l
total 0
-rw-rw-r-- 1 rene rene 0 Jan 1 00:07 foo
snap no: 9 | | | |
Alice/> git branch
* (HEAD detached at 3fd0cb8)
master
snap no: 10 | | | |
snap no: 11 | | | |
snap no: 12 | | | |
Alice/> git commit baz -m "add baz"
[detached HEAD 35855da] add baz
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 baz
snap no: 13 | | | |
Alice/> git checkout master
Warning: you are leaving 1 commit behind, not connected to
any of your branches:
35855da add baz
If you want to keep it by creating a new branch, this may be a good time
to do so with:
git branch <new-branch-name> 35855da
Switched to branch 'master'
snap no: 14 | | | |
Alice/> ls -l
total 0
-rw-rw-r-- 1 rene rene 0 Jan 1 00:13 bar
-rw-rw-r-- 1 rene rene 0 Jan 1 00:13 foo
snap no: 15 | | | |
Alice/> git merge 35855da
Merge made by the 'recursive' strategy.
baz | 0
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 baz
snap no: 16 | | | |
Alice/> ls -l
total 0
-rw-rw-r-- 1 rene rene 0 Jan 1 00:15 bar
-rw-rw-r-- 1 rene rene 0 Jan 1 00:15 baz
-rw-rw-r-- 1 rene rene 0 Jan 1 00:15 foo
snap no: 17 | | | |