0

I have a git repository at G:\C\BIT. It has two branches dev and master. master is empty and dev has three follders A, B, and C. Now when I am in dev branch then these folders show in computer. But when I checkout to master branch all the three folders A, B and C become invisible. Not only they are invisible but they don't take space on my hardisk too. G:\C\BIT in dev is 4 MB and in master 2.75 MB. My question is

  • Where do files of one branch go when I checkout to another branch? Are they hard deleted and then redownloaded when I checkout to the former branch again?
user31782
  • 7,087
  • 14
  • 68
  • 143

1 Answers1

3

Your git repository is stored in the .git directory of your working directory. When you check out a new branch, files may be added or deleted from your working directory, but they remain untouched in the git repository.

Git only operates on local files; while it has facilities for synchronization changes to and from remote repositories, actions like checking out a file or committing changes only affect the local repository.

larsks
  • 277,717
  • 41
  • 399
  • 399
  • To add to this answer it may be an interesting exercise for the OP to check the space taken up by the .git directory - it should show that the .git directory accounts for a significant and consistent portion of the 4MB and 2.75MB figures. – haggisandchips Oct 27 '16 at 14:29
  • Seems like this is exactly what is happening. there is a lot of data stored in `.git/objects` folder. And the data seems to be encrypted. Thanks. – user31782 Oct 27 '16 at 14:34
  • @haggisandchips I just pasted a 300MB folder in repository with `dev` branch checked. Now when I switched to `master `.git` is 300 MB. – user31782 Oct 27 '16 at 14:35