What is a workspace in Git?
Answer
The Git workspace is a versioned folder that is being monitored by Git for changes.
Imagine you have the following project structure:
c:\my-project
c:\my-project\.git
c:\my-project\index.html
c:\my-project\images
c:\my-project\photo.png
The path c:\my-project is the root workspace folder. Everything inside this path except the .git folder is part of workspace and is monitored by Git.
If you change anything within the workspace (you edit file, add a new one, remove a file, add or remove a folder or do just any other possible change in data), the Git is able to see the changes.
The .git folder is excluded because it has special meaning - this folder contains the repository data (information about the version history and all changes together with data of previous versions), so it is not supposed to be versioned.
Now, how does the Git know that some folder is a part of workspace and should be monitored for changes? It is looking for a .git folder. If the .git folder is in the folder or in some of its parent folders, it means the folder is a part of workspace and should be monitored.
If you delete the .git folder, you make the parent folder and all its content unversioned as you removed all the versioning information and left the current version only.
The workspace and data versioning can be managed by using Git commands.
Related Git job interview questions
How do you discard all changes from your local Git workspace?
GitSource control JuniorWhat is the most basic Git workflow that you can use every day?
GitSource control JuniorHow do you add changed files from your Git workspace to Staging Area (Index)?
GitSource control JuniorWhat is .git folder?
GitSource control JuniorHow do you check what files are changed in your Git workspace?
GitSource control Junior