Hello there, how’d you like to learn about more on GitHub? So welcome to the part 2 of the GitHub and chill. In this section, I will be talking about,

  • Remote Repositories
  • GitHub
  • Push
  • Pull
  • Tags
  • Aliases

Basically the reason why you want to use GitHub is, GitHub is going to allow you to host your code repositories online.

So first things first, go to https://github.com and create an account for yourself.

Screenshot (172)

Remote repositories are normally read only. However since it is going to be your account it will allow you to read and write, since you will be authorized to do so.

Then  what you have to do is either push or pull updates to this remote repository.

After you create an account go to the right hand corner and click on the little + sign and you are going to see “create new repository”. Click on it and you will be taken to the below page.

Screenshot (175)

Inside the repository name you have to give some type of a name that is unique. And then you have to type in a description. I’m just using a dummy repository.

I’m going to leave the checkbox public and leave the next checkbox unchecked, and hit the create repository button. That’s it now what you have to do now is set everything up on the local side.

Screenshot (176)

Open up the terminal and go to the dirctory you want to push. (In this case I’m going to use “C:\Users\Achala\Documents\TestGithub” directory)

git init

git add .  => Type the space and period correctly

git commit -m ‘initial project version’

These commands will stage all new modified files and directories.

Screenshot (177)

Screenshot (178)

Then we have to jump back over to the GitHub and copy the link showed below. So basically this is going to be named as origin there after. Type,

git remote add origin https://github.com/Achala007/TestGithub.git

Screenshot (179)

Then type the below command to push the whole directory. This will do all the work done for you and upload that to GitHub.

git push origin master

Screenshot (180)

And if you go back in to GitHub, the whole directory with all the information is there.

Screenshot (181)

And I will click on the add a read me file. Then a little window is going to open up.

Here I’m just going to type in “info to my TestGithub repository” (Just type in something).

Screenshot (182)

And then click on commit new file. Then inside the repository you are going to see README.md file.

Screenshot (183)

Now what we are going to do is PULL this updated information inside of the terminal. This is the way to pull files inside of GitHub how to your local server.

If I would want to list all of these remotes and URLs that I have connected here type,

git remote -v

git fetch origin => Gets data from the remote, but it doesn’t merge changes with your work

Screenshot (185)

However if I want to actually pull all the directory files down along with any changes I would have to type in, (copy the origin fetch statement and paste after git pull). This will update everything.

git pull  https://github.com/Achala007/TestGithub.git

Screenshot (187)

So all of the files which were in the github direcory are now in here. (Type in ls and see for your self).

Now lets see how to put a file in my local server and then have it get uploaded in the github.

I have created another xml file named local.xml and saved it in the same directory that you are using on GitHub.

After creating a file type,

git add Local.xml

git commit -m ‘Added Local.xml’

git push

Screenshot (188)

If you go back to the GitHub you will see the Local.xml file in your repository.

Let’s reverse the process and check !

Next I will go to the Local.xml file which is inside the GitHub and edit the file. And commit changes. (I’m going to add a new greeting line)

Screenshot (189)

Now you can go back to the terminal and pull down these changes, type

git remote -v

git pull  https://github.com/Achala007/TestGithub.git

The open this file in a basic text editor. You will notice that the change has been successfully done.

Then let’s see how to update to GitHub. Just do a slight change in the same file and save it.

(I added  another greeting line to the Hello.xml). Then type,

git add Hello.xml

git commit -m ‘Added greet5 line’

git push

Screenshot (190)

And this change can be seen if you go to github and open the Hello.xml file.

Let’s have a look at tagging, tagging is basically used to tag files at any point in history. If you want to see all the tags that you currently have on your system type,

git tag  => (Probably empty ?)

If I want to create an tag for my previous commit

git tag -a V0.1 -m ‘Version 0.1’

git tag => Now you”ll see your tag

And if you want to see the information regarding that tag type,

git show V0.1

You can push your tags in to the github by typing,

git push origin V0.1

You can see these tags in the releases tab in git hub.

Screenshot (192)

Let’s move on to Aliases – they will provide you shortcut ways to do all sort of different things. This line will create an alias to the word commit as ‘co’

git config –global alias.co commit

Then you can later use this alias ‘co’ instead of using commit.

The last thing I will discuss is how to clone a repository.

First go to the Github and click on the Github logo in the left corner which will direct you to the home page of Github. Then click on explore to find a repository to clone. Then inside the search bar type in a random keyword. (I have typed google).

Screenshot (194)

Then go inside a random repository and click on the fork.

Screenshot (195)

And if I want to clone go to clone URL and  copy it.

Screenshot (196)

Go back to the terminal and to get all of these type,

mkdir google

cd google

git clone https://github.com/Achala007/google.git  => copied URL

Screenshot (197)

That’s basically it ! So this is the second part of Github and Chill ! In the next part I will be explaining things like,

  • Branching
  • Commits
  • HEAD
  • Checkout
  • Merge Conflicts
  • Merge Tool
  • Re-basing
  • Reset
  • Clean

Well that’s it !! Hope I made sense in to you guys on Commonly and frequently used commands come across when working with Github. If you have anything to be clarified you can drop a comment  or contact me. Thank You !

20 thoughts on “GITHUB and Chill – Part : 2

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s