I have a case whereby I regret to commit a code on top of a commit. Since I have not yet push the change, I want to change my commit based on another parent commit. This what I did to make it happen:

$ git rebase --onto [new parent hash] [old parent hash]

After I executed this command, there are some conflicted files. I resolved the conflicts, and continue the rebase using this command:

$ git rebase --continue

By now, new commit created on that parent commit with my changes applied. Thanks to git rebase.

Posted in Uncategorized.

Open project window: Alt-1
Generate code or create new: Alt-Insert
Go to Navigation: Alt-Home
Show terminal: Alt-F12
Open new terminal tab: Ctrl+Shift+T
Close terminal tab: Ctr+Shift+W
Select method to override from parent class / interface: Ctrl-O
Go to method in current class: Ctrl-F12
Switch between active editor tabs: Alt-Left or Alt-Right

Posted in Uncategorized.

Terminal is very useful tool on our IntelliJ Idea editor. Unfortunately, this terminal does not recognize git commands since it is configured by default to run cmd.exe. When we are already get used to use git command on the terminal, running git command on this terminal could save us from opening another git command line outside our editor.

Follow this step to configure our editor:
1. Click File > Settings...
2. Browse to Tools > Terminal
3. Change Shell path from "git.exe" to "[path to git installation]\bin\sh.exe --login"
4. Click OK.

Now when you open new terminal on IntelliJ Idea, it will recognize git commands.

Posted in Uncategorized.

This is git command we can execute from command line to browse when there is no editor.
Once we get hash of a commit (eg. from git log command) we can look into that commit information using git cat-file

First, we can use git log to obtain the commit hash: $git log --oneline --decorate --graph --all
output:

* 117826d (HEAD, origin/master, master) Add .gitignore
* af606a6 Initial commit

To check if the hash is a commit: $git cat-file -t 117826d
output:

commit

To check the commit detail: $git cat-file -p 117826d
output:

tree a3f84d1bfbe30dbf340f8fc34ea6dcb643afbf4b
parent af606a6a54070289384ad57aa763ce36020469e2
author User  1430399773 +0800
committer User  1430399826 +0800

To check the filel under this commit: $git cat-file -p a3f84d1b
output:

100644 blob cd3d2f4b1b1855bcd3d83966ac7907a2f46bca6c    .gitignore
100644 blob 072e5e57717b1c6097806209c1565ca68f2813d5    build.gradle
040000 tree 666e30ac8fabbd7cc7bbaccff94314b3f3f85327    gradle
100644 blob 91a7e269e19dfc62e27137a0b57ef3e430cee4fd    gradlew
100644 blob 8a0b282aa6885fb573c106b3551f7275c5f17e8e    gradlew.bat
100644 blob b318381fe4b0c5e7a460b4295ece4d55f6f9a85d    helloworld.iml
100644 blob 31258af8faeca28e68d996886f89523756ee70e2    settings.gradle
040000 tree 26ed19d88a76b22b8c5e5a0f2339fc08759afca6    src

We can do the same for the file hash: $git cat-file -p cd3d2f4b
output:

.idea/
.gradle/
build/
Posted in Uncategorized.