The Escherichia coli genome consists of a conserved part, the so-called core genome, which encodes essential cellular functions and of a flexible, strain-specific part. Genes that belong to the flexible genome code for factors involved in bacterial fitness and adaptation to different environments. Adaptation includes increase in fitness and colonization capacity. Pathogenic as well as non-pathogenic bacteria carry mobile and accessory genetic elements such as plasmids, bacteriophages, genomic islands and others, which code for functions required for proper adaptation. Escherichia coli is a very good example to study the interdependency of genome architecture and lifestyle of bacteria. Thus, these species include pathogenic variants as well as commensal bacteria adapted to different host organisms. In Escherichia coli, various genetic elements encode for pathogenicity factors as well as factors, which increase the fitness of non-pathogenic bacteria. The processes of genome dynamics, such as gene transfer, genome reduction, rearrangements as well as point mutations contribute to the adaptation of the bacteria into particular environments. Using Escherichia coli model organisms, such as uropathogenic strain 536 or commensal strain Nissle 1917, we studied mechanisms of genome dynamics and discuss these processes in the light of the evolution of microbes.