Yes, they are identical in meaning. It is a contraction, like "don't" in English. In formal writing, contractions are used less often, also like in English. You probably wouldn't see "don't" in a legal document, right? It's the same story.
Similar are: 이것이 >> 이게 and 저것이 >> 저게
Also, with the topic/contrast marker: (이/그/저)것은 >> (이/그/저)건
And with the direct object marker: (이/그/저)것을 >> (이/그/저)걸
A quick google search of, for instance, "는 게 어떻습니까" will show you 15,000 examples of this contraction used in formal cases. There is no rule against it, per se.
In fact, 거 is just another spelling of 것 that is used in certain circumstances.
Yet another contraction with 것 is in the probable future form, 것이다 and it's permutations, where the ㅅ and the 이 contract out, giving 거다, 겁니다, 거지, etc.
There are more.
One thing to point out is that 게 is used other ways, for example to make adverbs and passive forms from verb roots, so be careful to pay attention...in fact i found this a bit confusing when first learning the language.