Expanding universe - does the Hubble red shift come from gravity? Measurement of the expansion of the universe is based, in part, on the red shift of light. The speed of light is a constant, although some people argue that it may be changing over time, I am going to ignore that argument for now.
But light can lose energy to gravity. In other words, if you look light from a large mass, it will be red shifted by the gravity of the mass. So, while light from our sun travels at the same speed all across the solar system, it is red shifted at the edge of our solar system.
So, does the red shift used by Hubble come from expansion or from gravity?
Are we measuring expansion by assuming that light does not lose energy to the gravity it has escaped?
 A: There are two ways I can answer this question. I'm pretty sure one of the ways is, while technically correct, mostly worthless to you because it ignore the question you're trying to ask and focuses on the question you did ask. So let's start with that one.
The redshift used by Hubble comes from expansion only and from gravity only. In general relativity, gravity is a description of how spacetime is curved and how it behaves. The expansion of space can be written into the Einstein field equations as reacting to gravity; being driven by it, influencing it, and being influenced by it. Therefore, it is valid for us to say that redshift due to expansion is "technically" due to gravity (the LHS of the EFEs, for all you technical enthusiasts). So it is both.
Okay, the second way to answer this is more helpful to what you wanted to ask, so I thought I'd save the best for last.
The redshift Hubble measures is due to the expansion of space. One of the primary ways it measures expansion is by measuring the redshift from Type-1A supernovae, which has a spectrum and intensity that is always the same. Let me present two strong reasons why you can be sure that Hubble isn't measuring redshift due to gravity from the star or other objects along the way. Firstly, we do the math. We calculate how much redshift we should see purely due to the source star, which always has the same mass because of how these supernovae are produced. This allows us to remove it from the measurements. Second, even were we to not do this, the amount of redshift is roughly consistent for all Type-1A supernovae. So we can look for one fairly close to us, where the redshift due to expansion would be expected to be minimal, and we can then use that as a base line to eliminate gravitational redshift from ones that are further away. Any left over redshift must be due to expansion. Additionally, we know that other objects on route do not provide much redshifting because if something of large mass was in the middle of the light's path, it would gravitationally blueshift as it approached the object and redshift by (almost) exactly the same amount as it left. A net cancelling effect.
So what Hubble uses is the redshift due to expansion. And we do not assume there is no gravitational redshift, we just have very easy ways of nullifying its effects
A: From expansion of the universe, the expansion of the universe is a repulsive force. Why it is a force? Because just like gravity, it is from spacetime, eventually it pushes atoms apart
