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?

5
  • 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 Commented Mar 21, 2022 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. Commented Mar 21, 2022 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. Commented Mar 21, 2022 at 15:04
  • Please keep in mind that the .git folder is the repository. Commented Mar 21, 2022 at 15:06
  • 1
    I think your question is addressed by this answer. Commented Mar 21, 2022 at 15:08

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.