Version control plays a major role in the industry. Version control is inevitable when a project is collective contribution of large number of team members, where each of them check in the code into a centralized repository. The purpose of the blog is to help some of my team members to clone a repository from GitHub.
Cloning : “git clone url” will clone online repository to your hard drive so you may begin working on your modifications. The local copy is called your local repository.
1. Setting the name and default email
To associate user name with the commits, user name can be set by the command:
git config --global user.name "Name"
To associate the email address with the commits,email id can be given by command:
git config --global user.email "email@example.com"
2. Check if the repo is public or private:
Go to the url where your repository is present in the GitHub. On the top left of the page, you can see an icon, which specifies if the repository is public or private. (Please see figure 1 for details). If the repository is public, you don’t need the keys to clone your repo.
3. Clone the repo:
Steps to Clone the repo if it is public:
A git clone should work, either in git bash or the Linux shell. If the repo is public, you don’t need keys to clone the repo. You can clone the repo using the following command:
git clone firstname.lastname@example.org:FFmpeg/FFmpeg.git
Steps to clone the repo if it is private:
If the repo is private, you need to add the public key to the account.
1. Check if the keys already exist in .ssh folder, by the command:
2. Generate the SSH key:
If the keys are not present, generate the ssh key with the command:
ssh-keygen -t rsa -C "email@example.com"
You will find two files, id_rsa, which is private key and id_rsa.pub, which is the public key, in ~/.ssh folder.
Go to the Account settings on the top right corner in the GitHub page as shown in the figure. Click on SSH keys and Add SSH key. Copy the contents of id_rsa.pub there.
A git clone should now work!!!!