As explained in last post you came to know how to commit the changes done at your local working directory. Lets start with Github and working with its repositories
GitHub
GitHub is a hosting service for Git repositories. You can store your local committed files in Github repositories and collaborate with your team members.
Create your account in GitHub using this link : GitHub
We need to generate SSH key for our GitHub account. Well, lets form the SSH key using following command:
$ ssh-keygen -t rsa -C "Enter your email id here"
$ ssh-keygen -t rsa -C "Enter your email id here"
Example code:
$ ssh-keygen -t rsa -C "sukhesh222@gmail.com"
$ ssh-keygen -t rsa -C "sukhesh222@gmail.com"
After executing this command your bash terminal will asks for file to save public key and passphrase. Enter the details. Now it will displays the file location where your public key has been stored. Copy the key from the file and paste in GitHub and then click on "Add SSH key" button as specified in below path:
Login to GitHub account->Profile->settings->SSH and GPG Keys
Login to GitHub account->Profile->settings->SSH and GPG Keys
Now create your repository in GitHub account. For demo I had created repository named "DemoProject".
Push operation
Now we need to add the remote to our local project. Lets run the following command.
$ git remote add DemoOrigin https://github.com/sukhesh222/DemoProject.git
$ git remote add DemoOrigin https://github.com/sukhesh222/DemoProject.git
As given in the command we are adding a new remote location for our project and given a name for our remote as "DemoOrigin" and the remaining url is a path of our repository.
Now lets push our locally committed folder to the repository using following command.
$ git push -u DemoOrigin master
$ git push -u DemoOrigin master
This command pushes and stores all the files presented in the staging area to GitHub repository. Refer the detailed coding sample screenshot given here:
You can access these files using your github url. As shown in examples here I can access my Github repository and project using the link "https://github.com/sukhesh222/DemoProject.git".
Clone operation
Clone command is used for downloading the files from your Github repository to your local system. we will create a folder named "downloaded" inside our local working directory "myProject". Then lets execute the clone command as given below.
$ git clone https://github.com/sukhesh222/DemoProject.git c:/xampp/htdocs/myProject/downloaded
$ git clone https://github.com/sukhesh222/DemoProject.git c:/xampp/htdocs/myProject/downloaded