What is Repository?
In simple terms, it is the central location in which data is stored or managed. A
virtually stores a particular file and allows you to save and access it’s version.
Initializing a Repository
To create a new repository the
command is used. It is used to convert an existing project to git repository.This is the first and one time command we use during initialization of a new repository. When git init command is executed,
subdirectory is created.This includes subdirectories for objects,template files etc. An initial head file or new master branch is also created.
git init (directory)
This creates an empty git repository to the specified .
git init command initializes the repository
Running git init on a project directory that already contains .git subdirectory will not override existing .git configuration on using git init again.
- -q–quiet Only print error and warning messages. All other output is silenced.
- –bare It creates a bare repository. It is used when you are collaborating with other developers and need a space to share each other’s changes. For this, a bare repository is created at a central place where everyone can push their changes.
- –template=(template_directory) It specifies the directory from which files are copied into the repository.
- –SHARED[=(FALSE|TRUE|UMASK|GROUP|ALL|WORLD|EVERYBODY|0XXX)] It sets the access permissions for the new repository. Few Examples are:-
- group (or true): Make repository group- writable.
- all (or world or everybody) :-Same as group, but make the repository readable by all users.
This command is used when the project is already their in the central repository.Like git init, git clone is also one time command.
git clone (repository URL)
git clone is used to create a copy of remote repositories. We pass git clone a repository URL.
Following Images shows the cloning of repository file from github into the local repository directory
- –branch It allows you to point to the branch pointed to the cloned repository’s head instead of pointing to newly created head.
- –template It clones the repository at and applies the template form to the newly created local branch.
Other options are
–mirror, –bare, –origin
and many more.
Very simple way to distinguish them is to note the point that git clone is dependent on git init. git clone is used to create a copy of existing repository but git clone itself first calls git init to create new repository.
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses
are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!