Upload Project to GitHub

In this tutorial, You will see, How can you upload the Project to GitHub or How can you upload project from our local to our server.

In previous tutorials, we have done all configurations. Now we will see, How can we communicate to server from our local machine and send stuff to the server from local.


We will upload the project from local to Server. In Git, we will use Git Bash to perform these all. We will learn about the GIT in details in Git Tutorial till then please have a look on necessary commands.


Let’s see how can we upload the project to Server.


  1. Go to the Directory, Which you want to upload on the server.(Suppose I am going to upload SeleniumBix source code)
  2. Right-click on the directory and select the option ‘Git Bash Here‘. This will open the Git Bash and auto keep the location of your Project. You have no need to pass your desired directory location.
  3. You can use command ‘pwd’ to verify the working directory. (Git Bash accepts Linux command, So you can use Linux commands here)
  4. To upload the Project, First you have to initialize the Git inside your project directory so run the command ‘git init‘. This command will initialize the Git and create the hidden .git folder inside your project directory. You can see this using the command ‘ls -a‘.
  5. Now add your all files to Git using the command ‘git add ‘ . This will add your all files to Git. Your files are actually not uploaded to your server yet. Add command keeps the file in some stage state.
    To add files one by one you can use command ‘git add filename
  6. To write your files to the server. You need to commit your changes using the command —
    ‘ git commit -m “my first commit” ‘
    This will list your all files, what will commit, This “my first commit” is the comment here, you can write anything here but this comment will become your commit signature on GitHub.
  7. Now add your repository to the origin. As I want to add repository named SeleniumBix so my command will be —
    git remote add origin https://github.com/anshulc55/SeleniumBix.git
    (You also have the easy way to do it, Create the New Repository on GitHub but don’t check in the Readme.me file checkbox at the time of repository creation and copy the command from GitHub)
    Upload Project to Jenkins
  8. Now push your all files on Git using command —
    git push -u origin master


If you are getting some error like this —

To https://github.com/anshulc55/SeleniumBix.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to ‘https://github.com/anshulc55/SeleniumBix.git’
hint: Updates were rejected because the tip of your current branch is behind
hint: it’s remote counterpart. Integrate the remote changes (e.g.
hint: ‘git pull …’) before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push –help’ for details.


Then you need to first perform the pull from your master branch because some differences are there in your local and server repository so you need to merge first before pushing the code. To merge the code use command —

git pull 


Now again perform the push command if error is still there then push the files forcefully using command–

git push -f origin master


It will push your project on server successfully. You can see the confirmation below.

0 Comment

Leave a Reply