Charles Dustin Collins, 29, was charged with assault on a peace officer and assault with a deadly weapon.
Judge Peter Gallagher set bail at $100,000. Collins faces five years in prison if convicted.
The shooting took place along a trail shortly after 2 p.m. Thursday, San Diego police Lt. Jorge Duran said.
A state ranger was responding to a call about a nude man when he came upon Collins inside a tent, the lieutenant said.
The ranger ordered Collins out of the tent and to show identification, prompting him to become verbally combative, Duran said.
The ranger called for backup, and another ranger arrived a short time later. At some point, Collins allegedly grabbed a knife and turned toward one of the rangers in a threatening manner.
Duran said one of the rangers fired a single shot that hit Collins in the body.
The name of the deputy who shot Collins was not made public. He was described by authorities as an eight-year veteran of the state Department of Parks.
San Diego police detectives are investigating the shooting.
A readiness conference was set for Jan. 7 and a preliminary hearing for Jan. 21.