Skip to content

Instantly share code, notes, and snippets.

@jimmycuadra
Created March 25, 2011 16:22
Show Gist options
  • Select an option

  • Save jimmycuadra/887126 to your computer and use it in GitHub Desktop.

Select an option

Save jimmycuadra/887126 to your computer and use it in GitHub Desktop.
Oops, my commit should have been on a branch
[rvm 1.9.2] ~/Code $ mkdir gittest
[rvm 1.9.2] ~/Code $ cd gittest/
[rvm 1.9.2] ~/Code/gittest $ git init
Initialized empty Git repository in /Users/jimmy/Code/gittest/.git/
[rvm 1.9.2] ~/Code/gittest (master)$ touch foo
[rvm 1.9.2] ~/Code/gittest (master)$ git add foo
[rvm 1.9.2] ~/Code/gittest (master)$ git ci -a -m "initial commit"
[master (root-commit) 700ec02] initial commit
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 foo
[rvm 1.9.2] ~/Code/gittest (master)$ echo "this should have been on a branch" > foo
echo "this should have been on a branch" > foo
[rvm 1.9.2] ~/Code/gittest (master)$ cat foo
this should have been on a branch
[rvm 1.9.2] ~/Code/gittest (master)$ git st
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: foo
#
no changes added to commit (use "git add" and/or "git commit -a")
[rvm 1.9.2] ~/Code/gittest (master)$ git ci -a -m "update foo"
[master 3728b85] update foo
1 files changed, 1 insertions(+), 0 deletions(-)
[rvm 1.9.2] ~/Code/gittest (master)$ git lol
* 3728b85 (HEAD, master) update foo
* 700ec02 initial commit
[rvm 1.9.2] ~/Code/gittest (master)$ git branch feature
[rvm 1.9.2] ~/Code/gittest (master)$ git reset --hard HEAD~1
HEAD is now at 700ec02 initial commit
[rvm 1.9.2] ~/Code/gittest (master)$ git lol
* 700ec02 (HEAD, master) initial commit
[rvm 1.9.2] ~/Code/gittest (master)$ git branch
feature
* master
[rvm 1.9.2] ~/Code/gittest (master)$ git co feature
Switched to branch 'feature'
[rvm 1.9.2] ~/Code/gittest (feature)$ git lol
* 3728b85 (HEAD, feature) update foo
* 700ec02 (master) initial commit
[rvm 1.9.2] ~/Code/gittest (feature)$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment