GitHub is the best place where we can share our code with friends and others programmers. It provide us best code management functionality. On GitHub every developer can share code. Here you can show your skills. On GitHub by using we can control over code version by committing code on Git. GitHub is a web based Git repository hosting service. GitHub is a largest code hosting service. In this tutorial we will install Git and commit code on GitHub step by step. Here I am using Ubuntu operating system.
1. First of all open your terminal and locate in a directory where you want to crate local repository
vickey@vickey-System:~$ cd /home/Desktop vickey@vickey-System:~/Desktop$
2. Now use the following command to create local repository
vickey@vickey-System:~/Desktop$ git init PHP
when repository created you will see the below line in your terminal
Initialized empty Git repository in /home/vickey/Desktop/PHP/.git/
It will create a new directory with name "PHP"
3. Now change your directory
vickey@vickey-System:~/Desktop$ cd PHP vickey@vickey-System:~/Desktop/PHP$
4. Here with the below command create a README file where you will describe about the repository
vickey@vickey-System:~/Desktop/PHP$ gedit README
I used gedit editor you can use other editor. Write your content in the file and save the file
5. This is the important part of this tutorial here we will add our code and files which we will push on GitHub. For now here I am creating a file name as info.php with the below code.
Now we have two files in "PHP" directory 'README' and 'info.php'
6. Now index these files by using the below commands
vickey@vickey-System:~/Desktop/PHP$ git add README vickey@vickey-System:~/Desktop/PHP$ git add info.php
This git add command will be used for every file which you have in your directory
7. After files added we will commit these on server
vickey@vickey-System:~/Desktop/PHP$ git commit -m "your message here"
8. Now login your GitHub account and create repository with the name same as you have on your local system. Once you have done run the below command in your terminal. Note that 'vickey' is the GitHub account username please change it first.
vickey@vickey-System:~/Desktop/PHP$ git remote add origin https://github.com/vickey/PHP.git
9. And in last push your code on server
vickey@vickey-System:~/Desktop/PHP$ git push origin master Username for 'https://github.com': vickey Password for 'https://email@example.com': To https://github.com/vickey/PHP.git * [new branch] master -> master