6. Let the set $M=\left\{a \left\lvert\, a=\frac{x+y}{t}\right., 2^{x}+2^{y}=\right.$ $2^{t}$, where $x, y, t, a$ are all integers $\}$. Then the sum of all elements in the set $M$ is ( ).
(A) 1
(B) 4
(C) 7
(D) 8
6. D.

Assume $x \leqslant y$, then $2^{x}=2^{x}+2^{y} \leqslant 2^{y}+2^{y}=2^{y+1}$.
Thus, $t \leqslant y+1$.
From $2^{x}>0$, we get $2^{t}=2^{x}+2^{y}>2^{y}$. Therefore, $t>y$.
So, $y<t \leqslant y+1$.
Given that $x, y, t$ are all integers, then $t=y+1$. Hence, $2^{y+1}=$ $2^{x}+2^{y}$, which means $2^{x}=2^{y}$. Therefore, $x=y=t-1$.
Thus, $a=\frac{x+y}{t}=2-\frac{2}{t}$.
Here $a, t \in \mathbf{Z}$, so $t= \pm 1, \pm 2$.
Then $a=0,1,3,4$.
Therefore, the sum of all elements in set $M$ is $0+1+3+4=8$.