Suppose you have a matrix $X \in \mathbb{R}^{n \times p}$ and the projection matrix in least squares is defined as:
$$ H = X(X^TX)^{-1}X^T $$
where note that the first column of $X$ are ones.
Now suppose that you define $Y = X - \boldsymbol{1}_{n\times 1} C^T$ where $C \in \mathbb{R}^{p \times 1}$ and $C_1 = 0$. So $Y$ is defined as $X$ shifted by some constant amount, $C_i$ subtracted from the $i$-th column of $X.$
How do we show that
$$ H' = Y(Y^TY)^{-1} Y^T = H $$
Here is my attempt (i'm going to drop the bold on the column vector of 1s): $$ H' = Y(Y^TY)^{-1} Y^T \\ = (X - 1C^T)((X - 1C^T)^T(X - 1C^T))^{-1}(X - 1C^T)^T \\ = (X - 1C^T)((X^T - C1^T)(X - 1C^T))^{-1}(X^T - C1^T) \\ = (X - 1C^T)(X^TX - X^T1C^T - C1^TX + C1^T1C^T)(X^T - C1^T) \\ = (X - 1C^T)(X^TX - X^T1C^T - C1^TX + C1^T1C^T)^{-1}(X^T - C1^T) \\ $$
I stopped here because I know this is going to get messy and will probably involve block matrices, and I think there should be an easier solution than what I'm undertaking?
I believe there's an argument that can be made about how $H$ is spanned by the same basis before and after shifting since $X$ is defined to have a column of ones, so any column of $Y$ can be written as the corresponding column of $X$ and the first column of $X$.
The matrix $X$ in this scenario is typically tall and skinny, having many more rows than columns. The matrix $X^TX$ is invertible precisely if the columns of $X$ are linearly independent.
If $u$ is in the column space of $X$ then $u=Xb$ for some column vector $b$ with only as many entries as $X$ has columns, and then a simple algebraic computation shows that $Hu=u.$
But if $u$ is orthogonal to the column space of $X$ then $X^Tu= 0$ and so $Hu=0.$
Thus for any column vector $u$ as "tall" as $X,$ the vector $Hu$ is the orthogonal projection of $u$ onto the column space of $X.$
Therefore, the matrix $H$ depends on $X$ only through the column space of $X.$ If $Y$ is another matrix whose column space is the same as that of $X,$ then $H'=H.$