Monday, November 20, 2017

Uki2 Class 10 + Git Commands

10th day @ Uki....

We did the continuity of Time Table coding and then practiced in Github to push our coding to Github site.

Github

Github is an online storage repository used by developers to push their coding/ programming source codes to edit it wherever or which device platform in this world. Its very useful to handle the source code. The following are the steps to push the files to online github repository in Ubuntu OS.

 1 Installing Git for Linux
We have to open the Terminal in Ubuntu and type the following..
sudo apt-get install git


2 Configuring GitHub
After the installation we have to configure our Github account to create an online repository in Github site.

 git config --global user.name "user_name"
git config --global user.email "email_id"

we have to enter our Github user name in user_name place and then type our e-mail address in the place of email_id.

3 Creating a local repository
Then we have to create a local folder that is repository in Online cloud storing folder which will be pushed to Github later.

git init

If the process is success we will receive 

Initialized empty Git repository in /home/akshay/html/.git/

Note: This command should be typed in the folder where your coding folders which are going to be pushed are saved.

4 Adding repository files to an index

Next, we have to add the files to the repository.

git add index.html

here index.html is a file's which is going to be pushed.
You can add whole files in the folder using 

 git add . or git add *

6 Committing changes made to the index
After we add files... we have to commit that the files to be uploaded are finalized and ready to push.

 git commit -m "some_message"

"some_message" is user's description. You have to replace it with your description.

7 Creating a repository on GitHub

 Notice that the name of the repository should be the same as the repository's on the local system. 

That is your folder's name and github's repository names should be the same.

To do this login to your account on https://github.com. Then click on the "plus(+)" symbol at the top right corner of the page and select "create new repository".  

Then you have to type the folder's name in the first form...

Then click  "create repository" button.

Once this is created, we can push the contents of the local repository onto the GitHub repository inside the profile.

Then type this command and replace the link with your repository URL

git remote add origin https://github.com/user_name/html.git


8 Pushing files in local repository to GitHub repository

The last step is to push the local repository files into the GitHub, using the following command:

git push -u origin master

Then you have to enter your user name of github and password...

After that your repository is created on Github...

9 To Clone an Existing Repository
If you want a working copy of your repository on another machine

git clone https://github.com/user_name/repo_name.git  

10 To pull changes from Github Repository
git pull

No comments:

Post a Comment