Showing posts with label GIT Remote Repository. Show all posts
Showing posts with label GIT Remote Repository. Show all posts

Friday, 28 December 2018

GIT: What is a bare Git repository?

The standard way of initializing a new Git repository is to run git init. The directory in which you do this will be become the Working Tree for the repository.
As part of the initialization process, Git creates a .git directory (which his hidden by default because of the . in the name) that contains the repository itself. This is brains of the repository; it's where Git tracks your changes, stores commit objects, refs, etc. You probably only rarely interact with that hidden directory.
Okay, so all of this is to lay the groundwork for understanding a bare Git repository. What the heck is it?
A bare Git repository is a repository that is created without a Working Tree. Go ahead and create one to see.
git init --bare .
Run ls on that directory and you won't see a Working Tree but just the contents of what is typically in the .git directory.
Why this setup?
A bare Git repository is typically used as a Remote Repository that is sharing a repository among several different people. You don't do work right inside the remote repository so there's no Working Tree (the files in your project that you edit), just bare repository data.
And that's it.

GIT: What is a Git Remote Repository

By default Git is completely local to your computer. You can optionally have remote copies of the repository (either on a central server or service—like Github—or on a co-workers computer).
To get your copy of the repository up to a remote server you use the command git-push. If you want to retrieve others’ changes to the repository you use git-pull.
A Remote Repository in Git is a special type of repository in that it doesn't have a Working Tree. This is different than your local repository, which has your project files and then a hidden .git directory.
You can host your own Git remote repository or use one the popular online services, like GithubGitlab, or Bitbucket.