I'm sorry, I don't quite get what you mean by
> I understood ... This is incorrect.

As to my understanding, commit operation is only allowed on working branch. So if you want to make a new commit based on #B when the current HEAD is on #D:
```
A<-B<-C<-D     master(HEAD)
```
You have to checkout #B first. (Either by `checkout my_branch` or `checkout SHA1#B -b my_branch`). 

```
A<-B      my_branch(HEAD)
    \
     C<-D     master
```
Then you can make a new commit #C' based on #B
```
A<-B<-C'      my_branch(HEAD)
    \
     C<-D     master
```