Skip to content

Instantly share code, notes, and snippets.

@Supernats
Last active October 2, 2015 00:04
Show Gist options
  • Select an option

  • Save Supernats/c546c4e220101fd9406a to your computer and use it in GitHub Desktop.

Select an option

Save Supernats/c546c4e220101fd9406a to your computer and use it in GitHub Desktop.
~/personal$ mkdir git_test
~/personal$ cd git_test/
~/personal/git_test$ git init
Initialized empty Git repository in /Users/baldur/personal/git_test/.git/
~/personal/git_test$ echo "hi i'm a commit" > first.txt
~/personal/git_test$ git add first.txt
~/personal/git_test$ gcom -m "This is my first commit"
[master (root-commit) 129986c] This is my first commit
1 file changed, 1 insertion(+)
create mode 100644 first.txt
~/personal/git_test$ echo "hi i'm more text" > second.txt
~/personal/git_test$ git add second.txt
~/personal/git_test$ gcom -m "this is my second commit"
[master 101f075] this is my second commit
1 file changed, 1 insertion(+)
create mode 100644 second.txt
~/personal/git_test$ echo "hi i'm the last text" > third.txt
~/personal/git_test$ git add third.txt
~/personal/git_test$ gcom -m "this is my last commit"
[master 6b8e42d] this is my last commit
1 file changed, 1 insertion(+)
create mode 100644 third.txt
~/personal/git_test$ git log
commit 6b8e42d7db7b19b3731e7351f4da4486ebe55cd9
Author: Nathan Seither <[email protected]>
Date: Thu Oct 1 17:00:26 2015 -0700
this is my last commit
commit 101f07526414e2f5f9d589fb6da242db5c7823a1
Author: Nathan Seither <[email protected]>
Date: Thu Oct 1 17:00:03 2015 -0700
this is my second commit
commit 129986c33c633e94711deffee95fdd966e8bd458
Author: Nathan Seither <[email protected]>
Date: Thu Oct 1 16:59:12 2015 -0700
This is my first commit
~/personal/git_test$ git rebase -i HEAD^^
Successfully rebased and updated refs/heads/master.
~/personal/git_test$ git log
commit fbb1d153a3124a731ed3754d81eab6e44a3091d4
Author: Nathan Seither <[email protected]>
Date: Thu Oct 1 17:00:26 2015 -0700
this is my last commit
commit 129986c33c633e94711deffee95fdd966e8bd458
Author: Nathan Seither <[email protected]>
Date: Thu Oct 1 16:59:12 2015 -0700
This is my first commit
~/personal/git_test$ git reflog
fbb1d15 HEAD@{0}: rebase -i (finish): returning to refs/heads/master
fbb1d15 HEAD@{1}: rebase -i (pick): this is my last commit
129986c HEAD@{2}: rebase -i (start): checkout HEAD^^
6b8e42d HEAD@{3}: rebase -i (finish): returning to refs/heads/master
6b8e42d HEAD@{4}: rebase -i (start): checkout HEAD^^
6b8e42d HEAD@{5}: commit: this is my last commit
101f075 HEAD@{6}: commit: this is my second commit
129986c HEAD@{7}: commit (initial): This is my first commit
~/personal/git_test$ git reset --hard 6b8e42d
HEAD is now at 6b8e42d this is my last commit
~/personal/git_test$ git log
commit 6b8e42d7db7b19b3731e7351f4da4486ebe55cd9
Author: Nathan Seither <[email protected]>
Date: Thu Oct 1 17:00:26 2015 -0700
this is my last commit
commit 101f07526414e2f5f9d589fb6da242db5c7823a1
Author: Nathan Seither <[email protected]>
Date: Thu Oct 1 17:00:03 2015 -0700
this is my second commit
commit 129986c33c633e94711deffee95fdd966e8bd458
Author: Nathan Seither <[email protected]>
Date: Thu Oct 1 16:59:12 2015 -0700
This is my first commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment