1

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?

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
SWW
  • 11
  • 2
  • The location of the `.git` folder is the root of the repository. So yes, they need to be in a folder in the same context – Liam Mar 21 '22 at 15:02
  • Yes, the `.git` folder lives in the root directory of the repository. Files that you want to track can live in that root directory or in subdirectories. – 0x5453 Mar 21 '22 at 15:03
  • It's theoretically possible that the `.git` directory is separate from the files to be kept track of, but unless you know what you're doing I wouldn't recommend it. – mkrieger1 Mar 21 '22 at 15:04
  • Please keep in mind that the `.git` folder _is the repository_. – evolutionxbox Mar 21 '22 at 15:06
  • 1
    I think your question is addressed by [this answer](https://stackoverflow.com/a/3082740). – mkrieger1 Mar 21 '22 at 15:08

0 Answers0