An (n, k, r) locally repairable code (LRC) is an [n, k, d] linear code where every code symbol can be repaired from at most r other code symbols. An LRC is said to be optimal if the minimum distance attains the Singleton-like bound d ≤ n−k −⌈k/r⌉+2. The generalized Hamming weights (GHWs) of linear codes are fundamental parameters which have many useful applications. Generally it is difficult to determine the GHWs of linear codes. In this paper, we study the GHWs of LRCs. Firstly, we obtain a generalized Singleton-like bound on the i-th (1 ≤ i ≤ k) GHWs of general (n, k, r) LRCs. Then, it is shown that for an optimal (n, k, r) LRC with r | k, its weight hierarchy can be completely determined, and the i-th GHW of an optimal (n, k, r) LRC with r | k attains the proposed generalized Singleton-like bound for all 1 ≤ i ≤ k. For an optimal (n, k, r) LRC with r ∤ k, we give lower bounds on the GHWs of the LRC and its dual code. Finally, two general bounds on linear codes in terms of the GHWs are presented. Moreover, it is also shown that some previous results on the bounds of minimum distances of linear codes can also be explained or refined in terms of the GHWs.