Introduction to Git

Monday, September 7, 2015

Git Rocks!!!

Git is a third generation distributed version control system

Advantages:

  1. Easy and lightweight to use
  2. Works on changesets
  3. Clients and servers can have entire repository present, locally
  4. Different topologies, centralized and hierarchical, and distributed
  5. Backups are easy, each clone is a full backup
  6. Reliable branching and merging, feature branches, always work under version control
  7. Full local history, compute repository statistics, analyze regressions
  8. New ideas, use DVCS's for deployment

About:

  • Created by Linus Torvalds who also created Linux
  • Started in 2005
  • Written in Perl and C
  • Runs on Linux, OS X, Windows and many other operating systems
  • Desing goals:
    • Speed
    • Simplicity
    • Strong branching and merging support
    • Distributed
    • Scales well for large projects

Install Git onto windows at this url


Download the bits to download folder and launch the installer


Configure the components


Make this selection to adjust the path environment for windows command prompt


Take the default for line ending conversions


Fire up the command prompt, power shell or git basch and check if the correct version has been installed


Navigate to a local directory and create a new directory, navigate inside it


Use git init to create a repository


Issue a git config global list to get properties from the system


Set the color property to auto for git to show the git commands in many colors


Set the handling of carriage return line feeds to be converted to solely line feeds


Check out the configurations made


Modify the users name by specifying the property


View the name is set at the bottom of the list


Use the unset command to rollback one


Initialize a repository with git init, use echo to add a text file, run status command and view there is one untracked file


Run git add and then view status, the file is being tracked


Issue git commit command to add the file to repository


Use vim readme.txt to access the file in the editor, add a second line


Git status knows that there are changes to the file


Use the -u on the add commamd to check in all changes


Use git status to see the file hs been commited onto staging


Git commit with -m allows to add the comment inline


View there are 2 commits in reverse chronological order, the most recent one is at the top


Use git diff to view the changes between commits


Git provides different syntax instead of working with cryptic sha1 strings, use Head command with tilda to go one back


Use touch command to add files to the repository


With git status view the files are not tracked and have not been added


Execute git add -u adds the files to the staging area but not to the repo because -u only takes updates into regard


Use -A to add all files even the untracked ones, also possible to add the files by file name, run git status view the files have been added to staging and ready to be commited


Run a git commit -m with an inline comment


Git log shows all the comits including the most recent ones on top


Do a diff view the new files added


Do a cat file1.txt and nothing appears because the files are empty, they only have been added to the repository, edit the readme text file


Add some text to file1.txt


Do a git status and view two changes in the working copy


Do a git add file1.txt and then get the status, file1.txt is on the staging


Do a git commit the file is moved from staging to the main root


Do an add and commit for the second file


Remove file2.txt using rm command and then run a status


Default Success Warning Important Info Inverse
B S W I ? O