What is a workspace in Git?

Experience Level: Junior
Tags: GitSource control

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.

Comments

No Comments Yet.
Be the first to tell us what you think.
Git for beginners
Git for beginners

Are you learning Git ? Try our test we designed to help you progress faster.

Test yourself
25 Git questions that will help you to nail your job interview
25 Git questions that will help you to nail your job interview

Are you learning Git ? Try our test we designed to help you progress faster.

Test yourself