1) CLIMBING OUT OF A TREE ON SHABBOS
OPINIONS: The Gemara points out an apparent contradiction between two Beraisos. One Beraisa states that a person who climbed up a tree is permitted to climb back down on Shabbos. The other Beraisa states that he is not allowed to climb down; he must stay in the tree until Shabbos departs.
The Gemara explains that the Beraisos refer to two different cases. When a person climbed up the tree before Shabbos began, he is permitted to descend the tree on Shabbos. If he climbed the tree after Shabbos began, he must remain in his place until Shabbos ends.
Why is one permitted to climb down the tree on Shabbos when he climbed up before Shabbos?
(a) RASHI (DH Im Alah) implies that when the person climbed the tree, he had intention to descend before Shabbos. Rashi says that if "he ascended while it was still day [on Erev Shabbos], and, before he knew it, Shabbos had arrived (v'Kidesh Alav ha'Yom), we do not penalize him and he may descend." Rashi seems to suggest that since he had planned to descend prior to the onset of Shabbos, he may climb down on Shabbos because he did not do anything wrong intentionally. (This is similar to the second answer of the Gemara, that one Beraisa discusses a case of one who climbed the tree on Shabbos b'Shogeg, and the other Beraisa discusses a case of one who climbed b'Mezid.) The TUR (OC 336) records such a ruling, and writes that only if one climbed with intent to descend before the start of Shabbos may he descend on Shabbos.
(b) However, the MAGID MISHNEH infers from the wording of the RAMBAM (Hilchos Shabbos 21:9) that even one who intended to climb down after Shabbos arrived is permitted to descend on Shabbos. Permission is granted because the transgression was passive (he remained in the tree at the start of Shabbos) and not active (he did not climb it on Shabbos). This is also the ruling of the RITVA here, as well as the KORBAN NESANEL (10:11:10).
HALACHAH: The SHULCHAN ARUCH (OC 336:1) cites both opinions. The MISHNAH BERURAH (336:10) rules leniently, like the Rambam's opinion. He permits anyone to climb down, even one who ascended before Shabbos with intention to descend on Shabbos. This seems to be the majority opinion.
One is also permitted to descend when he climbed the tree on Shabbos, if he did not realize that it was prohibited to do so, as the Gemara says here in its second answer.