I’ve heard from a Rabbi that if you forgive others, Hashem will forgive you for all your sins. What is the source for this? So is saying the “ I hereby forgive whoever has hurt me, And whoever has done me any wrong;”, at night before sleep, get you mercy from Hashem for him to forgive you for all your sins? Please list sources. Thanks.
Stop it right there!
First, get rid of your false assumption "Hashem will forgive you for all your sins". If this was the case it would render Rosh Hashanah and Yom Kippur and Yom Hadin obsolete. Since they are not, your assumption is therefore false.
Keep in mind that all general rules we learn from the Talmud are only a general correlation, not a law. That is explicitly said in Kiddushin 34a:
אמר רבי יוחנן אין למדין מן הכללות ואפילו במקום שנאמר בו חוץ
Rabbi Yoḥanan says: One does not learn practical halakhot from general statements, i.e. when a general statement appears in a Mishna and uses the term: All, it is not to be understood as an all-inclusive statement without exceptions. This is the case even in a place where it says: Except, to exclude a specific matter.
- Your question (and Kouty's answer) is a subset of a bigger rule - מידה כנגד מידה (Mishna Sotah 1,7) WIKI here:
"בַּמִדָּה שֶׁאָדָם מוֹדֵד, בָּהּ מוֹדְדִין לוֹ"
In the measure that a person measures, so it is measured out to him.
But once again, to translate it into our language: "one who [wholeheartedly] forgives others will be judged more favorably that one who does not [on Yom Kippur or Yom Hadin].
- Still, another point is that if one counts on that a-priori, that he can sin and then forgive someone and G-d will forgive him, the Talmud says (Mishnah Yoma 8,9)
"האומר אחטא ואשוב. אחטא ואשוב. אין מספיקין בידו לעשות תשובה. "
One who says, "I will sin, and then repent, I will sin [again], and then repent," will not receive an opportunity to repent;