Git: Where exactly is the “working directory”?

后端 未结 6 467
抹茶落季
抹茶落季 2021-02-01 04:08

I am going through some Git tutorials. The concept of a \"working directory\" keeps being mentioned, however, none of the tutorials or documents I read points out where

相关标签:
6条回答
  • 2021-02-01 04:27

    Do you work directly in the local repos?

    When I follow Microsoft's instructions [ref. https://docs.microsoft.com/en-us/azure/devops/repos/git/clone?view=azure-devops&tabs=visual-studio ], that's where I end up opening the .sln solution file. That seems wrong to me and unfortunate, because I prefer to work on code on my massive D: drive (D:\dev) rather than in C:\Users\\source\repos, where the repos are kept by default (I don't mind the local repos being kept there - it's not ideal - as long as I can work in my D:\dev area).

    0 讨论(0)
  • 2021-02-01 04:41

    To kind of combine the two other answers:

    As stated in the Git Documentation:

    The working directory is a single checkout of one version of the project.

    This essentially means if you checkout a branch (e.g. master) and are sat on a particular commit (e.g. HEAD), your working directory is the "umbrella" term for all your files and folders.

    It isn't a particular directory/folder though. The working directory covers all directories, files...everything.
    I mention this because when you want to commit some files, those files will be in the working directory and you'll need to stage them (using git add) before committing them (using git commit).

    0 讨论(0)
  • 2021-02-01 04:41

    According to the documentation:

    Finally, you have your working directory. The other two trees store their content in an efficient but inconvenient manner, inside the .git folder. The Working Directory unpacks them into actual files, which makes it much easier for you to edit them. Think of the Working Directory as a sandbox, where you can try changes out before committing them to your staging area (index) and then to history.

    0 讨论(0)
  • 2021-02-01 04:48

    Its is wherever you have checkout the project. For example the directory within which you have checked out a branch of your project. Its is typically the folder that contains the .git folder. That is the working directory. When you make changes to files in your checked out branch you make changes to the working directory. At this point the working directory has uncommitted changes. So initially when you haven't made any commits the working directory will be clean as there are no changes.

    0 讨论(0)
  • 2021-02-01 04:48

    The working directory is simply, your current local directory that you are working on. e.g if you have master, dev and yourname-dev as your remote branches, if you checkout from dev to yourname-dev, yourname-dev is now your working directory if you checkout from this (yourname-dev) working directory to another say dev, dev is now your new working directory

    0 讨论(0)
  • 2021-02-01 04:49

    This should hopefully clear things up for us:

    What is the difference between a repository created using the git init command and the git init --bare command?

    Repositories created with the git init command are called working directories. In the top level folder of the repository you will find two things:

    A .git subfolder with all the git related revision history of your repo
    A working tree, or checked out copies of your project files.
    

    Repositories created with git init --bare are called bare repos. They are structured a bit differently from working directories. First off, they contain no working or checked out copy of your source files. And second, bare repos store git revision history of your repo in the root folder of your repository instead of in a .git subfolder. Note… bare repositories are customarily given a .git extension.

    Taken from John Saints - What is a bare git repository?

    A bare git clone does not contain a working directory of checked out code, in other words.
    Think of it as just the .git directory (the Git database) without anything else.

    0 讨论(0)
提交回复
热议问题