How to get rid of discontinuities at the start of a signal caused by the filter
If you are post processing you can instead use a &quot;zero-phase&quot; filter which passes the signal through the filter twice in the forward and reverse direction, resulting in an output that is completely aligned with the input as would be expected with a filter with no delay, and with a significant reduction in start-up deviations (this is a non-causal filter hence the restriction on postprocessing).
Such a filter is available in MATLAB, Octave and Python scipy.signal as filtfilt which has further documentation on its use.
I demonstrate this as shown with the plot below using a traditional 91 tap FIR low pass filter for an in-band cosine signal and again with the same coefficients with filfilt (in red). Notice there are no transients or delay.

As far as any residual transient as @MBaz astutely points out, below is the plot zoomed in on the first 4 samples showing the filtered output as (+) and the original signal as (o). The line plot simply connects the output samples. This is due to the fractional cycle remaining at the end of the sampled data where I did worst case with a 1/2 cycle residual in the capture; if done with an integer number of cycles there would be no such mismatch.

And the same portion of the waveform later in the sequence showing close alignment.

However in comparison to the blue line in the first plot even in this worst case condition, we do see the significant reduction in the start-up transient due to the use of the zero-phase filter (limited to post-processing applications). The alignment of the input and output is also a huge plus for analysis applications where we many otherwise have to go through additional efforts to offset our waveforms for the delay when comparing input to output.