-1

I am trying to understand Git workflows. If for example I see following random pictures taken from on the net:

Git workflow 1

Git workflow 2

Git workflow 3

They show a Remote directory and 3 Local directories namely Working dir, Staging area and Local Repo. So far what I have understood is that all the 3 local directories are the names of physically 1 directory, the one where I have cloned the remote repo for example. While I can switch this local repo into 3 different logical states, namely working dir, staging area and local repo.

Please correct me if I am wrong in this understanding.

Marina
  • 13
  • 4

1 Answers1

0

Let me explain to you in simple words with the help of an image;

enter image description here

The local file system where git resides in your local machine is called as Local Repository. Let say it as a collection of everything, which resides in your computer.

Now, when you switch to one branch, you will be able to access / see files belonging to that branch. These files are present to you virtually. Which means, all files associated with other branches are hidden (not like hidden files) from you and you are presented with some files only. Lets say, the Local repository contains all files, but everything other than that particular branch are hidden from your eyes. Now, the area where you see all these files are called Workspace. So, for your understanding, lets say Local Repository + Branch = Workspace / Working directory.

Again, when you make changes to files in a branch, they are temporarily saved (staged) before permanently saving (commit) it. You may add / remove / modify files in that area before finalizing your changes. This space is called as an index.

Once you commit your changes, your files will be permanently stored in a branch, and that location where those files resides is called Local Repository.

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Alfred
  • 21,058
  • 61
  • 167
  • 249
  • does it mean the same thing as I stated in my post or was my understanding not correct? – Marina Jan 07 '22 at 09:40
  • let us say I am checkout on branch A of my local repo and I have 10 files in this branch. Also I have another branch B in this git repo which has only 5 files in it. When I switch to branch B from branch A and I goto my git repo folder on my filesystem then how many files will i see over there, 10 or 5? – Marina Jan 07 '22 at 10:56
  • @Marina you will see only 5 files corresponding to branch B. Also, if you find my answer helpful, please don't forget to upvote and (or) to accept it. – Alfred Jan 07 '22 at 16:08
  • I just learnt that .git directory means the 'Local repository'. This helps me to understand your answer now. Maybe you can include this info in your answer as well. – Marina Jan 07 '22 at 17:56
  • Is it correct to say that "Index" is also inside the "Local repository" or in other words .git directory? – Marina Jan 08 '22 at 08:25
  • @Marina yes, Index is also inside Local repository. In short, there is nothing lying outside local repository. – Alfred Jan 10 '22 at 06:52