The Gradient tool doesn't work exactly the same as the paint bucket tool in Photoshop (it's more for direction control). You just need to select the area you want to apply the gradient to first.
Ctrl + Click (or CMD + Click if you're on a Mac) on the thumbnail of the layer that has your brush strokes to create a selection based on that shape, then use the gradient tool to apply the gradient in that area only.

Just updated Photoshop, what has happened to gradient tool?
How to fill a rectangle with gradient color | Photoshop Gurus Forum
[HELP] Fit gradient to shape?
Adding gradient fills? - Content - SitePoint Forums | Web Development & Design Community
Videos
The Gradient tool doesn't work exactly the same as the paint bucket tool in Photoshop (it's more for direction control). You just need to select the area you want to apply the gradient to first.
Ctrl + Click (or CMD + Click if you're on a Mac) on the thumbnail of the layer that has your brush strokes to create a selection based on that shape, then use the gradient tool to apply the gradient in that area only.

While Vicki's answer helped you get the results you might want to start learning about Layers and the benefits they offer. Since you mention using the Paint Bucket tool it sounds like you're working on a single Layer.
So you probably have something like:

Ideally, you'd instead want them to be on a new Layer, like this:

But, let's say you have something you really like and don't want to start over so I'll use the case of the first one in the rest of this. Like you discovered you can Paint Bucket the inner areas. Likewise you can select areas to fill with gradients. Let's take that a step further.
- Select the areas you want to have the gradient:

- Create a new Layer using Shift+Ctrl/Cmd+N or the 6th button from left on the bottom of the Layer Window

- Now fill it with the
Paint BucketorEdit > Fill(Shift+F5

- Now the magic happens by added a Gradient Overlay:


The Benefits
Let's say shortly after doing that you want to change the Gradient, then double click on the Gradient Overlay effect in the Layer Window and you can change it:


Let's say now you're working and want to add another area with the Exact Same Gradient. Well just add it to the Layer portion using a Brush or Select/Fill and anything you add on the Layer will pick up the Gradient Overlay:

Hi, animation student here, I’m pretty experienced in Photoshop, but I’ve recently updated to Photoshop 2024, and I can’t figure out how to attach my own colours to the gradient tool. When I click the tool, I can only see the default options given. Any clue?
Hello all. Is it possible to fit a gradient to a shape. Now just as an example, I have the letter H and want a gradient to start from the bottom edges and the middle edge of the letter. So that the effect is not global.
Can someone help?