Getting Started with Basic Github Shell Command Operations

Of late I was working with my buddies on some open source projects hosted in GitHub. In my continuous journey I was learning some basic Shell commands through which Git management can be easily accomplished. In this short tutorial, I am going to narrate on how to do simple Git operations through Git Shell. As a prerequisite download and install GitHub tools for Windows – http://windows.github.com/. In case if you are finding problems with Git Shell, check out this StackOverflow question.

=======================================================================================================

Create Repository

=======================================================================================================

Logon to GitHub account and navigate to Repositories tab. Click on New.

image

Enter relevant details and click Create Repository.

image

Once repository created, we will land up with following summary.

image

 

=======================================================================================================

Clone Repository

=======================================================================================================

Open Git Shell for Windows by clicking below icon (which should be coming along with GitHub tools for Windows installation).

image

It will open PowerShell console and by default point to the local location where GitHub has been pointed too (Unfortunately I forgot on how I configured that location at the time of installation, from my sub-conscious memory I remember it is pretty straight forward).

image

Now we need to get GitHub Clone URL. Check out below screen shot.

image

Now execute the following command.

image

Once cloning has been done, we can get into the Master branch of the Repository.

image

Local GitHub repository can also be navigated through windows explorer.

image

=======================================================================================================

Create a Branch

=======================================================================================================

It is always a good practice to create a branch of master and work on it. One should have a healthy Master copy to make replicas of branches, so that different people will work on different releases, features and bugs.

Use following commands to create a branch locally, then push it to GitHub and finally change the context of shell from Master to created branch.

image

With above steps you can check our newly created branch in GitHub portal.

image

=======================================================================================================

Commit to a Branch

=======================================================================================================

now we can go ahead and make changes to the repository files in local. For simplicity, I am going to add Test.txt (a sample text file) and edit README file. Save changes in local.

image

Now make a Git Status call.

image

Add the changes to present context.

image

Commit the changes.

image

Finally push the changes to GitHub Repository.

image

NOTE: Origin is created at the first time cloning of the repository. It creates a path to commit and push changes to online GitHub Repository from ta local cloned repository.

We can check online GitHub repository now to check whether our changes are available or not.

image

=======================================================================================================

Fetch latest from a Branch

=======================================================================================================

To demonstrate fetch concept, let us update Test.txt file in the GitHub Portal. Click the Test.txt file and there by it can be edited using Edit option at the top and then finally commit changes to the file.

image

To get this change to our local, we can execute following commands.

image

And now if we go and check the local repository text file, changes will be reflected.

image

=======================================================================================================

Merge Branch with Master

=======================================================================================================

As a final step of this tutorial, we are going to merge the branch version to our Master version. First we make sure we get the branch version up to date in our local.

image

Then merge the changes to Master.

image

We can cross check the updated master version in the GitHub portal.

image

This completed our first getting started tutorial for GitHub. In next set of tutorials, we are going to work with Forking of repositories, Merging with remote repositories and more complicated merge scenarios.

Happy Coding!!!

You may also like...

One Pingback/Trackback

    23 December 2013 at 5:12pm
    [...] Getting Started with Basic Github Shell Command Operations ...
  • TechNet Blogs
  • Mohan

    Nice..!! This an easy way to start using Git

  • Pingback: TechNet Blogs()