I am new in learning programming, and got stuck while learning Git. From what I have learned so far, if we want to use Git locally, we may first need to create a folder, and then create a Git repository inside with the git init command.
Are those files that wanted to be kept track of necessary to be in the same folder as the .git directory?
.gitfolder is the root of the repository. So yes, they need to be in a folder in the same context.gitfolder lives in the root directory of the repository. Files that you want to track can live in that root directory or in subdirectories..gitdirectory is separate from the files to be kept track of, but unless you know what you're doing I wouldn't recommend it..gitfolder is the repository.