Git- Setting up a Repository - GeeksforGeeks

05 Nov, 2019
What is Repository?In simple terms, it is the central location in which data is stored or managed. A git repository virtually stores a particular file and allows you to save and access it’s version.
Initializing a RepositoryTo create a new repository the git init 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, .git 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
NOTE:Running git init on a project directory that already contains .git subdirectory will not override existing .git configuration on using git init again.
Configuration
-q–quietOnly print error and warning messages. All other output is silenced.
–bareIt 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.
Git CloneThis 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
Options
–branchIt allows you to point to the branch pointed to the cloned repository’s head instead of pointing to newly created head.
–templateIt clones the repository at and applies the template form to the newly created local branch.
Other options are –mirror, –bare, –origin and many more.
Summarizing- git init VS git cloneVery 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.
nidhi_biet
Articles
GBlog
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Analysis of Algorithms | Set 1 (Asymptotic Analysis)
Time Complexity and Space Complexity
Mutex vs Semaphore
Analysis of Algorithms | Set 3 (Asymptotic Notations)
Analysis of Algorithms | Set 2 (Worst, Average and Best Cases)
Must Do Coding Questions for Companies like Amazon, Microsoft, Adobe, ...
Top 10 Front End Developer Skills That You Need in 2022
Socket Programming in C/C++
DSA Sheet by Love Babbar
Must Do Coding Questions for Product Based Companies