In this tutorial we will learn the following:
- Create a repository on github
- Install git client
- Clone the repository on local machine
- Upload (push) files to github from local
- Download (pull) files from github to local
Create a repository on github:
Press on the “+” button on top of navbar
Press “New Repository”
Give a name of repository
Give a short description
You can create a readme file by checking “Initialize this repository with a README”
At last press create repository button.
Your repository is created.
Installing Git Client
The following steps can be done using Git Shell(Windows) or Ubuntu terminal. Install Git in Windows: Download and install Github desktop. URL: https://desktop.github.com/ Install Git in Ubuntu: sudo apt-get install git
Clone the repository on local machine
click “copy to clip board” or copy text like “https://github.com/pollmix/tut.git”
Open git client (Git shell / terminal) on local machine
Go to working directory using “cd” command. like: “cd D:\XAMPP\htdocs\”
Type “git clone https://github.com/pollmix/tut.git”
A new folder will be created as repository name. Here “tut” folder will be created
Upload (push) files to github from local
First paste your files inside “tut” folder.
Now go to “tut” folder first: “cd D:\XAMPP\htdocs\tut”
We will see something like this “tut [master +1 ~0 -0 !]>”. Note that numbers are red that means files are not added.
So add all files to git, write: “git add –all”. Now it is like “tut [master +1 ~0 -0 ~]>” with green color that means files are added successfully.
Then we add a message to this current change. Type: git commit -m “upload complete”
After pressing enter show information will be displayed about the operation.
Finally upload the files using this command “git push -u origin master”
Download (pull) files from github to local
Say somebody changed the files of the project and pushed it to git. So before working with the project we must ensure that we have the latest code. That’s why we need to download the changed files. We only need the changed files only.
To do this type “git pull –all”. This will download all latest codes from git