I thought rebase would only carry the commits in 1 branch to another but looks like it's not.
This is the key: your commit 7 in your diagram is in branch feature. It's also in branch bugfix. Commits 1-2-3 are in all three branches.
Git's branches are very different from most other version control systems. A branch "contains" a commit only by virtue of being able to "reach" that commit from the commit to which the branch-name points. Branch names like master, bugfix, and feature simply point to one particular commit, which Git calls the tip of the branch. It's the commits themselves that form a chain, by having each commit "point back" to its predecessor.
Because of this, git rebase actually copies commits: you went from:
4--5--6 <-- feature / 1--2--3 <-- master \ 7 <-- bugfix
to:
4--5--6 [abandoned - used to be feature] / 1--2--3 <-- master \ 7 <-- bugfix \ D--E--F <-- feature
where D is a copy of the original 4, E is a copy of 5, and F is a copy of 6 (I used the 4th, 5th, and 6th letters here so we could copy 7 to G for instance, if we wanted, but this technique is about to run out of steam).
You can still get what you want, though. You just need to copy D-E-F again, or—this is probably nicer for this particular case—just go back to the abandoned, original 4-5-6.
When you use git rebase to copy commits, the originals stick around. There are two names by which you can find them: ORIG_HEAD, and reflog names. The name ORIG_HEAD is overwritten by various other commands, but you can check to see if it's still pointing to commit 6:
git log ORIG_HEAD
and you will probably recognize your originals.
The reflog names have the form name@{number}, e.g., feature@{1}. The number part increments every time you change the commit to which the name part points, as Git simply saves the current value of name in the reflog, pushing the rest all up a notch.
Hence:
git log feature@{1}
should show you the same commits as git log ORIG_HEAD, except that feature@{1} sticks around longer (maybe becoming feature@{2}, feature@{3}, and so on, over time). By default, the previous values for each name are saved for at least 30 days, so that should be enough time to get it back.
To get it back, use git reflog feature to see which number goes in the @{...} part and then, while on feature (git checkout feature), run:
git reset --hard feature@{1}
or whatever the number is (though verifying yet again with git log first is a good idea).
(This assumes you don't have anything to check in, i.e., that git status says everything is clean, because git reset --hard wipes out not-yet-checked-in index and work-tree changes.)