This study presents a higher-order optimal tracking controller for spacecraft formation keeping based on the discrete-time Hamilton-Jacobi theory. In the frame of a typical optimal tracking problem in discrete-time domain, an infinite-horizon optimal feedback controller in generic form is first derived by employing generating functions which represent two-point boundary value problem of Hamiltonian phase flow. This systematic approach does not require any initial guess or iteration. It is also not adversely affected by the complexity of performance index, dynamics, and desired tracking trajectories. The proposed higher-order controller is applied to a spacecraft formation keeping problem, which demonstrates superior tracking performance to optimal tracking controller in continuous-time domain in terms of both tracking error and fuel consumption.