Another interpretation: David said (Psalms 147:3): "He heals the broken-hearted." These are the tribes, whose heart was broken, saying that perhaps Joseph would kill them. (Psalms 147:4, same place:) "He counts the number of the stars." These are the tribes. Just as these stars go forth only by names, as it is said (same place): "He calls them all by names" — and likewise upon their entering they enter by a count, as it is said: "He counts the number of the stars" — so too the tribes: when they entered Egypt it is written (Deuteronomy 10:22): "With seventy souls your ancestors went down to Egypt," and when they went out, "about six hundred thousand on foot" (Exodus 12:37). And the tribes, because they had not gone down to Egypt, their names were specified; and once they entered, their names were specified, as it is said: "And these are the names of the children of Israel."
The Tribes Counted Like Stars Entering Egypt by Name
Midrash Tanchuma Buber, Shemot 2:3
ד"א אמר דוד הרופא לשבורי לב (תהלים קמז ג) אלו השבטים, שהיה שבור לבם לומר שמא יהרגם יוסף, מונה מספר לכוכבים (שם שם ד), אלו השבטים, מה הכוכבים הללו אינן יוצאין אלא בשמות, שנאמר לכלם שמות יקרא (שם), וכן בכניסתן נכנסין במנין, שנא' מונה מספר לכוכבים, כך השבטים כשנכנסו למצרים כתיב בשבעים נפש ירדו אבותיך מצרימה (דברים י כב), וכשיצאו כשש מאות אלף רגלי (שמות יב לז), והשבטים על שלא ירדו למצרים נתפרשו שמותם, ומשנכנסו נתפרשו שמותם, שנא' ואלה שמות בני ישראל.