There is growing recognition of the role of diet and other environmental factors in modulating the composition and metabolic activity of the human gut microbiota, which in turn can impact health. This narrative review explores the relevant contemporary scientific literature to provide a general perspective of this broad area. Molecular technologies have greatly advanced our understanding of the complexity and diversity of the gut microbial communities within and between individuals. Diet, particularly macronutrients, has a major role in shaping the composition and activity of these complex populations. Despite the body of knowledge that exists on the effects of carbohydrates there are still many unanswered questions. The impacts of dietary fats and protein on the gut microbiota are less well defined. Both short- and long-term dietary change can influence the microbial profiles, and infant nutrition may have life-long consequences through microbial modulation of the immune system. The impact of environmental factors, including aspects of lifestyle, on the microbiota is particularly poorly understood but some of these factors are described. We also discuss the use and potential benefits of prebiotics and probiotics to modify microbial populations. A description of some areas that should be addressed in future research is also presented.