Reading: Git – Getting a Git Repository
This creates a newly subdirectory named .git that contains all of your necessary repository files — a Git depository skeletal system. At this steer, nothing in your visualize is tracked however. See rotter Internals for more information about precisely what files are contained in the .git directory you good created. If you have a project directory that is presently not under version control and you want to start controlling it with Git, you first need to go to that project ’ mho directory. If you ’ ve never done this, it looks a fiddling unlike depending on which system you ’ re running :
Cloning an Existing Repository
If you want to get a copy of an existing Git repository — for example, a project you ’ d like to contribute to — the command you need is git clone
. If you ’ re companion with other VCSs such as Subversion, you ’ ll notice that the command is “ ringer ” and not “ check ”. This is an authoritative distinction — rather of getting equitable a knead copy, Git receives a wide copy of closely all data that the server has. Every version of every file for the history of the visualize is pulled down by default when you run git clone
. In fact, if your server harrow gets corrupted, you can often use about any of the clones on any customer to set the server back to the department of state it was in when it was cloned ( you may lose some server-side hooks and such, but all the versioned data would be there — see Getting Git on a Server for more details ).
You clone a repository with git clone
. For model, if you want to clone the Git linkable library called libgit2
, you can do so like this :
$ git clone https://github.com/libgit2/libgit2
That creates a directory named libgit2
, initializes a .git
directory inside it, pulls down all the data for that repository, and checks out a working copy of the latest version. If you go into the new libgit2
directory that was equitable created, you ’ ll see the undertaking files in there, ready to be worked on or used.
Read more: Microwave Scrambled Eggs
If you want to clone the repository into a directory named something other than libgit2
, you can specify the new directory mention as an extra argument :
$ git clone https://github.com/libgit2/libgit2 mylibgit
That command does the like thing as the previous one, but the target directory is called mylibgit
.
Git has a count of different transfer protocols you can use. The previous case uses the https://
protocol, but you may besides see git://
or user@server:path/to/repo.git
, which uses the SSH transfer protocol. Getting Git on a Server will introduce all of the available options the waiter can set up to access your Git repository and the pros and cons of each .