CodeSamplez.com

Programming, Web development, Cloud Technologies

  • Facebook
  • Google+
  • RSS
  • Twitter
  • Home
  • Featured
    • C# Tutorials
      • LinQ Tutorials
      • Facebook C# API Tutorials
    • PHP Tutorials
      • CodeIgniter Tutorials
    • Amazon AWS Tutorials
  • Categories
    • Programming
    • Development
    • Database
    • Web Server
    • Source Control
    • Management
    • Project
  • About
  • Write
  • Contact
Home Source Control Git Tutorial On Windows For Beginners

Git Tutorial On Windows For Beginners

Rana Ahsan December 30, 2010 3 Comments


 Git Tutorial On Windows For Beginners    

On this tutorial, I will describe how you can start using git on windows environment as your preferred version control system. I am assuming, you have basic knowledge about version/revision control system already, and may already used other version control systems already so that you know what commit/checkout/merge etc means.

What Is GIT:

In professional development, source control are an important criteria to be fulfilled. Either you want to preserve the ability to resume back to an older stable code version of a project, or want to have the ability to work concurrently with other developers on same files with minimal overhead, you will need some kind of version control system implemented, for sure. There are many systems for this kind of tasks like, SVN, Perforce, Microsoft TFS etc. GIT is comparatively new addition to this list. But, it has become one of the most popular now a days because of its benefits over others. Specially, the slogan fits very well with its criteria, which is ‘Fast Version Control System’. I am going to introduce with very basic idea to start working with git version control system on windows environment.

Understanding Git For Other Version Control Users:

If you are already using visual studio with other version controls like SVN or Microsoft’s own team foundation server and not used git yet, you will have to think about git a little differently. All of these version control systems are centralized, which means, after doing works, when you commit something, goes directly to the central repository, usually hosted on a centralized/remote server.

Git Is DVCS:

Unlike other source control management system I mentioned above, GIT is distributed. That means, we can use it as a local repository and also host it to a server. Each cloned git repository contains full revision history synchronized withe others and can be treated as a complete repository anytime. So, if your server is destroyed, you won’t lose the revision tree for your repository, your local copy can be reinstalled on server and will act as the old repository exactly in the same way. You can create new branch/merge with a revision without being connected to central/remote repository as well.

Installing GIT On Windows:

You have to go to official git website. Just download the windows installer from download section and install. it’s that much easy!

You will get two different version to use, one is command line tool(known as ‘GIT Bash‘), another is GUI Tool(GIT GUI). However, GUI tool’s functionality is very limited. So, it’s better not to use that and stick with command line tool, after a little practices, it will become easy for you.

Setting Basic Configuration:

Git recommends to set up your name and email globally so that it can use those info with your commits on revision history. To do so, open the git bash tool and write the following two lines:

$ git config --global user.name "Your Name"
$ git config --global user.email youremail@yourdomain.com

This is one time setup as you did it ‘globally’. It will work for any git repository that you will be creating in future.

Create And Initialization Of A Repository On GIT:

To create and initialize a repository, first you have to be on the directory you want to make as a repository. For this, you can re-use the ‘cd’ command line directive. Then, you have to run the initialization command. Additionally, you should configure your name/email on git global configuration for identification purpose. First, open GIT Bash tool. Write command statements as follows:

$ cd F:/MyProjectFolder
$ git init

Remember, don’t try to use windows directory structure with backslash(‘F:\MyDirectory’), that won’t work here. ‘init’ command makes the directory as a git repository and creates its necessary core files/directories(hidden).

If you want to retrieve source from an existing repository(whether it’s on locally or remotely), use this command instead:

$ git clone path-to-repository

This will get the latest version of the codes to current git directory. In this case, you don’t need using ‘git init’ command.

Add Files To GIT Repository And Commit:

first you will have to run the ‘add’ command for the file(s) you want to add to repository. Then need to add a commit command. Here are code sample to add all files in the directory and commit them to git:

$ git add .
$ git commit -m 'My First Commit'

You Should use comment for every commit. Remember, This commit will be made locally on your current git directory, nowhere else. If you have retrieved code from a remote repository and want have your commit as part of that, use the following additional command after the above ones:

$ git push origin master

This will upload the local changes/commits to the original git repository. In short, ‘git push’ would work as well in case you aren’t using multiple origins. If you created a local repository first and now want to upload/publish it to a remote repository, you can use command as below:

$ git add origin url-to-repo
$ git push origin

Further Updates And Commit On GIT Repository:

It is also quite easy. You just have to run ‘add’,’commit’ and ‘push'(if applicable) command after every updates are done. The new commits will only take place for the files those are changed.

Further References:

There are a lot more command options for more advance usage. I will suggest you to go through the git online book for learning more. Its free and very helpful. If you wish to host your project on a web server, you can should use github , which you can use either for public open source project(free of cost) and also private project(have to pay monthly fee). However, you can use assembla as well to get a free private repository up to 3 users.

Hope this small git tutorial on windows environment will help you in some extent for starting this amazing version control system which is now ruling the world of software development. Let me know if you have any comments/questions/suggestions. Happy coding 🙂

Related

Filed Under: Source Control Tagged With: git

About Rana Ahsan

Rana is a passionate software engineer/Technology Enthusiast.
Github: ranacseruet

Trackbacks

  1. Getting Started With github For GIT Project Hosting | codesamplez.com says:
    December 31, 2010 at 3:31 am

    […] updates on this topic.Powered by WP Greet Box WordPress PluginI have already discussed about how to get started with git. After you know the basics, you might want to start your projects and may be finding a suitable […]

    Reply
  2. Codeigniter Bundle With Popular Libraries And Best Practices | codesamplez.com says:
    December 19, 2012 at 9:09 am

    […] growing distributed version controlling system? To do so, you can start with my another tutorial on getting started with git. However, as an alternative, without doing git clone or so, you can download the latest version as […]

    Reply
  3. Useful Git Commands List | codesamplez.com says:
    December 20, 2012 at 3:05 am

    […] I have discussed about very very basics about git and about github. However, none of those tutorials covered the important git commands that is […]

    Reply

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Email Subscription

Never miss any programming tutorial again.

Popular Tutorials

  • How To Work With JSON In Node.js / JavaScript
  • PHP HTML5 Video Streaming Tutorial
  • How To Work With C# Serial Port Communication
  • LinQ Query With Like Operator
  • Facebook C# API Tutorials
  • LinQ To SQL Database Update Operations In C#
  • Using Supervisord Web Interface And Plugin
  • Tutorial On Uploading File With CodeIgniter Framework / PHP
  • Utilizing Config File In C#.NET Application
  • Using GIT Plugin For Netbeans IDE

Recent Tutorials

  • Building Auth With JWT – Part 1
  • Document Your REST API Like A Pro
  • Understanding Golang Error Handling
  • Web Application Case Studies You Must Read
  • Getting Started With Golang Unit Testing
  • Getting Started With Big Data Analytics Pipeline
  • NodeJS Tips And Tricks For Beginners
  • Apple Push Notification Backend In NodeJS
  • Web Based Universal Language Translator, Voice/Text Messaging App
  • How To Dockerize A Multi-Container App From Scratch

Recent Comments

  • S. Chalisque on PHP HTML5 Video Streaming Tutorial
  • Armorik on Generate HTTP Requests using c#
  • iswaps on PHP HTML5 Video Streaming Tutorial
  • TAKONDWA on PHP HTML5 Video Streaming Tutorial
  • rorenzo on PHP HTML5 Video Streaming Tutorial

Archives

Resources

  • CodeSamplez.com Demo

Tags

.net apache api audio aws c# cache cloud server codeigniter deployment doctrine facebook git github golang htaccess html5 http image java javascript linq mysql nodejs oop performance php phpmyadmin plugin process python regular expression scalability server smarty ssh tfs thread tips ubuntu unit-test utility web application wordpress wpf

Copyright © 2010 - 2022 · CodeSamplez.com ·

Copyright © 2022 · Streamline Pro Theme on Genesis Framework · WordPress · Log in