I have patterns and I want them be with the same gradient, but when I chose gradient it applies to all selected areas as a whole. And gradient is scattered to all selected areas. On the image u can see how gradien is applied independantly to patterns (the first row), it's done selecting each pattern independantly. The second row shows how gradient spreads on 2 paterns because patterns were selected at once. So how to make gradient like in the first row, selecting all patterns at once?
Use Illustrator as an auxiliary tool. Make a selection which is your all wanted areas together. I guess you can Ctrl+Click the layer icon.
In Paths panel convert your selection to work path with 0,5 px accuracy.
Select the work path with the path selection tool.
Copy and paste it to Illustrator, ungroup and release the compound path.
Select all paths and let them get the same gradient.
Copy and paste the shapes with gradients as pixels back to your Photoshop image. Placing it exactly is not automatic, you must move it manually with high zoom in to make everything fit.
For Photoshop to recognize each octagon as a separate object in order to apply a gradient or gradient layer style to it, they each need to be on their own layer.
Or you have to select each shape one at a time in order to limit the gradient tool to only the selected area.
There's no other way in Photoshop.
You could create one shape layer and apply the gradient fill to it. Then merely duplicate that layer and reposition it to create a pattern. (This is what I would do if restricted to Photoshop — Copy 3 times vertically, then select those three, copy once horizontally, select all 6 layers, group, copy group as often as necessary horizontally to fill out the pattern.)