Upload projects in GIT Hub

Git is a free and open source version control system. Its very easy to use and very popular version control system which handle small and large projects very efficiently.  Whereas GitHub is a hosting place to host your source code based on Git. On GitHub you can manage your projects, track issues and work in a team from anywhere in the world.

In this post I will show you how to create a repository on GitHub and clone the repository and upload the project on GitHub.

Steps to use Git & GitHub

Lets start a sample project. I will create Helloworld Java application in eclipse and upload the project on the GitHub. In the below steps I will show you how to clone a repository, commit project files and push into GitHub.

    1. Goto GitHub.com, and create an account. If you already have an account login on to the site.
    2. Before going to the next step download and install Git on your local system.
    3. On GitHub website create a new repository and name it SampleProject. When you click on create button you will get the project repository URL.
    4. Create a project folder on your local machine. And open the terminal window (on Windows command prompt).
    5. On the terminal window set the path to the newly created folder and execute the following command git clone repository URLGit Project
    6. Create a Java project in the folder. I am using eclipse to create a project. You can use any text editor. Even you can simply create a text file.

    7. Next in the terminal window execute the following command git status
    8. Add all the newly added files by entering command git add .
      Git Project
    9. Then commit the files git commit -m “comments”
      Git project 4
    10. In last step push the files on GitHub git push
    11. The files are successfully uploaded on the Git hub.
    12. Next I add a new file “IHelloWorld” as an interface. HelloWorld class implements the interface. Now I add a new file in the project and also modify the existing file.
      public class HelloWorld implements IHelloWorld {
      	public static void main(String[] args) {
      		System.out.println("Hello world. This is my first Git project");
      	public void InterfacePrint() {
      		System.out.println("Print statement from Interface method");
      public interface IHelloWorld {
      	void InterfacePrint();
    13. In command line type git status and it will tell the files added or modified.
      Git Hub Project
    14. You can individual files in Git by using file name or  use the following command to add all the files git add .
    15. Next use the commit command as shown in step 9 to commit the files. Finally execute push command (as shown in step 10) to put the files on the git hub.

    You can find the sample project on the following Git Hub Url. https://github.com/waqas80/SampleProject

Leave a Reply

Your email address will not be published. Required fields are marked *