In Git, to generate a repository, create a directory for the project if it does not exist, and then run command git init. By running this command . git directory will be generated in the project directory, the directory does not need to be empty.