Pages

Thursday, July 25, 2013

[Git] Quick tutorial for git on Windows

This post aims to show a quick guide to install git on a Windows machine, with CLI and GUI, and demonstrate some important commands for a beginner as me to use the git system.


What is git?
Git is a distributed version control and software management system, widely used in many software development projects.  The working directory assigned is called repository, with complete history and code tracking capability; a repository can be remote (on server) or local (on hard disk).

Installation
Step 1: Install git on Windows box (client)
Download and install MSYSGIT for basic functionalities (command line and basic gui)


Step 2: Install GUI
Download and install TurtioseGit, have a better GUI environment.

Build local repository
Right click on the folder icon and click "Git Create repository here..."

Check the repository using GUI


Register private remote repository

Use bitbucket, which provides free private repository in which can be accessed by 5 users at most.
You can also apply github with a paid account.

Set your remote url in TortoiseGit





















Use Puttygen to generate ssh keys





















Save pubic key as  ~/.ssh/id_rsa.pub
Save private key as ~/private_key.ppk
Copy the public key to your bitbucket (Manage Account -> SSH keys -> Add SSH key

















Basic usage




























  • Add (Assign which files should be tracked)
  • Git Commit -> "master..." (Make a record in local repository)
  • Show log (Check the version history)
  • Diff (Check what you have added/removed)
  • Push (Upload the repository to remote server)
  • Pull (Download the remote repository to local)
  • Switch/Checkout (restore the early version)
  • Create Tag... (Tag your commit/record)


    Other terms
    1. master: Typically, your latest version will stored in the branch "master"
    2. head: The last commit record

    You can also use commands
    http://spencerimp.blogspot.tw/2012/02/git-git-on-your-mac.html


    references
    http://dbanck.de/2009/10/08/github-windows-and-tortoisegit-part-1-installing-pulling/
    http://shaocian.blogspot.tw/2013/01/windows-git-msysgit-tortoisegit.html