In this post, I am going to show you how to create (or)
get a git repository.
Create a new Git
repository
Go to the project directory and execute ‘git init’
command.
For example, Create HelloWorld directory and execute ‘git
init’ command.
C:\Users\Public\gitDemos\HelloWorld>git init Initialized empty Git repository in C:/Users/Public/gitDemos/HelloWorld/.git/
Once you execute the command ‘git init’, it creates a new
subdirectory .git folder inside it.
.git folder contains multiple folders inside it.
Clone existing git
repository
By using 'git clone' command, you can clone the existing
git repository.
For example, the command ‘git clone https://github.com/junit-team/junit4.git´clones entire
junit git repository. Once you executed the clone command, it creates a
directory name junit4 and initializes a .git directory inside it.
C:\Users\Public\gitDemos>git clone https://github.com/junit-team/junit4.git Cloning into 'junit4'... remote: Counting objects: 56165, done. remote: Compressing objects: 100% (31/31), done. remote: Total 56165 (delta 6), reused 3 (delta 1), pack-reused 56132 Receiving objects: 100% (56165/56165), 22.16 MiB | 1.67 MiB/s, done. Resolving deltas: 100% (40228/40228), done. Checking out files: 100% (562/562), done.
Whenever you clone a repository, you will get all the
data of the repository, including history (not only the current working copy).
Note
a. How to clone the repository to separate directory?
git clone https://github.com/junit-team/junit4.git junitSourceCode
Above command copies all the git repository to
junitSourceCode folder.
No comments:
Post a Comment