We focus on the problem of pose-based gait recognition. Our contribution is two-fold. First, we incorporate a local histogram descriptor that allows us to encode the trajectories of selected limbs via a one-dimensional version of histogram of oriented gradients features. In this way, a gait sequence is encoded into a sequence of local gradient descriptors. Second, we utilize a robust encoding method in which the residuals of local descriptors, with respect to a discriminative model, are aggregated into fixed length vectors. This technique combines the advantages of both residual aggregation and soft-assignment techniques, resulting in a powerful vector representation. For classification purposes, we use a nonlinear kernel to map vectors into a reproducing kernel Hilbert space. Then, we classify an encoded gait sequence according to the sparse representation-based classification method. Experimental evaluation on two publicly available datasets demonstrates the effectiveness of the proposed scheme on both recognition and verification tasks.