Evolution history of virus tracing
The identification is done by sequencing virus samples and comparing them to reference genomes of viruses. By doing this, you can analyze how closely related an unknown virus is to the references. 

For the nCoV this method shows it is 96% identical with a known bat coronavirus (see reference 1 for details). 
As viruses accumulate mutations due to errors during replication, this method is also used to generate genetic trees of the virus to analyze how it spreads, map routes of infection and also if the virus has been introduced to humans more than once (reference 2 has a nice overview on this topic).

The problem here is: You need to have some known references for comparision, if you have a completely new virus which has never emerged before, this will not help. For this reason there are projects ongoing which collect samples to identify yet unknown viruses (see reference 3)


Discovery of a novel coronavirus associated with the recent
pneumonia outbreak in humans and its potential bat origin
DNA sleuths read the coronavirus genome, tracing its origins and
looking for dangerous mutations
Virome analysis for identification of novel mammalian viruses in
bats from Southeast China