How to upload to github: Tutorial for Ubuntu

If you haven't get a git hub account, create one here. Then click new repository from top right corner of your web browser as shown in following picture.

Once the repository is created, you will be given a link; just like in the following picture. You need it very soon.

Now we will create a folder name called gitHub and go into this folder.
$ cd ~/Documents/
$ mkdir gitHub
$ cd gitHub

Once the folder is created, we clone empty repository by following command.
$ git clone <link given to you>
For example;
$ git clone

Then you will see this kind of message
Cloning into 'Testing'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.

Now 'Testing' folder will be created by previous command. Now we go to 'Testing' folder  and create some simple text and save it.
$ cd Testing
$ gedit hellogithub.txt

We will want to see what changes are made in this 'Testing' folder. You can do it by typing following command.
$ git status

Then you will get this kind of message after that
On branch master

Initial commit

Untracked files:
  (use "git add <file>..." to include in what will be committed)


nothing added to commit but untracked files present (use "git add" to track)

Now we need add the changes in order to sync to repository.
you can specifically add the file
$ git add hellogithub.txt

you can add any files which are affected by the changes made by you.
$ git add --all

You need to specify the user name and email to git hub. You only need it for first time.These are the sample to setup user name and email.

$ git config --global ""
$ git config --global "Your Name"

So for example;
$git config --global ""
$git config --global "osdevlab"

Now we can first commit our first file. This step is required to track your change with useful info such as "first commit". This reflects the file in repository which is going to be committed for first time. You can also write a comment like "first try" or something like that.

$ git commit -m "first commit"

This step is where you really upload your files to git hub.
$ git push -u origin master

It will ask your user name and password. Just provide these and you are good to go. After your user name and password are provided, you might see the message below.

Counting objects: 3, done.
Writing objects: 100% (3/3), 230 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

For Subsequent uploading,
Go to the folder that has been setup with git
$ git add --all
$ git commit -m "subsequent commit"
$ git push -u origin master
Then it will ask for user name and password. Fill it in and you will see latest change in your repository.

No comments:

Post a Comment