SlideShare a Scribd company logo
GIT Intro and usage on
Windows - Basic
By Geshan Manandhar
http://geshan.blogspot.com
1http://geshan.blogspot.com
Agenda
 What is git
 Who uses it, features
 How to use git on windows
 Prepare working directory
 Create public repository
 Add, commit, pull, push
 Git ignore
 Other commands and things to look at
http://geshan.blogspot.com 2
GIT is
 a free & open source, distributed
version control system.
 designed to handle everything from small
to very large projects with speed and
efficiency.
 a developer’s friend in a multi
developer environment.
 a must tool to go back in history to what
you coded and see the code changes
made in the timeline.
3http://geshan.blogspot.com
Who uses GIT
 Many big names including
◦ Linux/Kernel
◦ Eclipse
◦ Ruby on Rails
◦ Android
◦ PostgreSQL
◦ Git itself.
4http://geshan.blogspot.com
Why use Git/ Features
 Fast
 Distributed (no central repository)
 Can work offline
 Small (file system usage)
 Has a staging area
 Access control (with gitosis)
 Fit for any project size
 Branching, tags …
 GitHub.com
◦ Reference: http://whygitisbetterthanx.com
5http://geshan.blogspot.com
Distributed??
 No Central
repository
 All developers
have a working
copy and own
private repo (.git)
 Code transfer
should be done on
non-private repo.
http://geshan.blogspot.com 6
Image Source:
http://coding.smashingmagazine.c
om/2011/07/26/modern-version-
control-with-git-series/
How to use on windows?
 Could not find mature GUI tools like
tortoise SVN.
 Integrated in Eclipse (with plugin) and
NetBeans (good colorful support).
 If you are programmer, you are not
scared of the command line so:
 Download MsysGit :
http://code.google.com/p/msysgit/dow
nloads/list
http://geshan.blogspot.com 7
MsysGit for git on Windows
http://geshan.blogspot.com 8
Steps:
1. Download the exe file (or the portable one, it will not need
installation).
2. Install msysgit , next … next is your friend here with finish – no
need of any fancy configuration.
3. Run the git bash application.
Git bash part of MsysGit
http://geshan.blogspot.com 9
User and line settings for win
 If you are familiar with ~ of unix systems
this might be easy.
 Make sure where your home dir is in
your windows setup like:
◦ /c/users/Geshan – for me in Windows 7
 Set ~/.bash_profile if you want.(google
bash profiles and dot files, if you want to)
 Run this: git config --global core.autocrlf true
 Have a look for new line setting if need be:
http://github.com/guides/dealing-with-newlines-in-git
http://geshan.blogspot.com 10
Introduce yourself to GIT
 execute commands in bash
◦ git config --global user.name <name>
◦ git config --global user.email <email>
◦ (this gets written to your ~/.gitconfig file)
 Example
◦ git config --global user.name “Geshan
Manadhar”
◦ git config --global user.email
“me@somedomain.com”
http://geshan.blogspot.com 11
Some conceptual clarity
 You have a working directory and your
private repo (a .git folder in your dir)
 You always push your changes and
pull changes from another non-private
repository.
http://geshan.blogspot.com 12
Working Dir with git
Public git repo on file system
Preparing your working dir
http://geshan.blogspot.com 13
Nothing significant just created a directory with a file that’s it.
Preparing working dir 2
http://geshan.blogspot.com 14
Working directory made
 Commands used
◦ git init ; to initialize the current dir for git
tracking.
◦ git status; shows current status
◦ git add; put files to stating area
 Variations like
 Git add . ; . Is for all changed files
 Git add /path/to/file ; /c/dir1/file1.txt
 Git add /path/a.*
 etc
http://geshan.blogspot.com 15
First commit
http://geshan.blogspot.com 16
git commit –m “message”;
Files have been put into the local repository (the .git dir
created with git init)
All things are in local so we need to push things to a non-
private repository. For this example I’ll create a local
repository.
Always remember to write concise but meaningful
commit messages.
Creating public repository
http://geshan.blogspot.com 17
A bare passive public repo has been created for pushing code.
Remember the path is /c/users/geshan/gitrepos/testgit.git
Different command : git init --bare;
Now we will link the working directory with this public repo.
Linking working dir with public
repo
http://geshan.blogspot.com 18
Remote repository created in previous slide linked to the working directory.
git remote add <name> <path>
Path can be:
File : /home/geshan/gitrepost/testrepo.git
Remote file: ssh://user1@domain1.com/home/user1/gitrepos/test.git
Gitosis: git@domain1.com:test.git
First push to remote repo
 git push <repo_name>
<branch_name>
 Repo_name is just a alias to the path.
 git push origin master
◦ Default repo when cloned in origin and
default branch is master.
http://geshan.blogspot.com 19
First pull attempt
 Pull is done to get the changes done
by others in the self working directory.
 git pull <repo_name> <branch_name>
 git pull origin master
http://geshan.blogspot.com 20
.gitignore file
 .gitignore file is generally placed in the
root of the working directory.
 As the name suggests it can ignore
certain files from git.
 Generally local config is ignored but a
back up is kept for others, example
database username password config.
http://geshan.blogspot.com 21
Using .gitignore
http://geshan.blogspot.com 22
Scenario:
Local database
settings are
stored in
database.php
file
Continue to push bkp file
http://geshan.blogspot.com 23
Pull by a new developer
http://geshan.blogspot.com 24
A new
developer
will
generally
clone the
project,
than
create
new files.
-Notice
git remote
–v
Git branch
shows
available
branches.
Scenario dev 2 posts code
 Dev 2 changed test.txt and pushed his
code to public repo.
http://geshan.blogspot.com 25
Dev 1 pulled the changes.
 Dev 1 can immediately have the
changed code.
http://geshan.blogspot.com 26
Gitk to know what changed
 execute gitk on a git repo root to get
this.
http://geshan.blogspot.com 27
Other git commands
 git log
 git short log –sne
 git checkout / git branch –b newbranch
 git tag v 1.0 –a “test”
 git fsck
 git push dev feature1; - testing you.
http://geshan.blogspot.com 28
Things to look at
 Reset the code to old version
 Branching with git
 Tagging with git
 How to handle conflict situation
 Other git features and commands
 Check out the git cheat sheet:
http://www.cheat-sheets.org/saved-
copy/git-cheat-sheet.pdf
 For details of hashing etc check the git
internals book.
http://geshan.blogspot.com 29
Happy Git-ing
 Google git
 See videos on youtube
 Find some good podcasts on git
 You will like what you use
http://geshan.blogspot.com 30

More Related Content

What's hot (20)

PDF
Version Control System - Git
Carlo Bernaschina
 
PPTX
Git in 10 minutes
Safique Ahmed Faruque
 
PDF
Git advanced
Peter Vandenabeele
 
PPTX
Advanced Git Presentation By Swawibe
Md Swawibe Ul Alam
 
PPTX
Introduction to git and github
Aderemi Dadepo
 
PPT
Git introduction
satyendrajaladi
 
PDF
GIT | Distributed Version Control System
Mohammad Imam Hossain
 
PPTX
Git 101
jayrparro
 
PPTX
From svn to git
Nehal Shah
 
PPTX
Git tutorial
Pham Quy (Jack)
 
PDF
What the Git? - WordCamp Atlanta
Nathaniel Schweinberg
 
PDF
Git training with Devaamo
Otto Kekäläinen
 
PPTX
Extra bit with git
gdgjss
 
KEY
The everyday developer's guide to version control with Git
E Carter
 
PDF
Version control
Giovanni Marco Dall'Olio
 
PDF
Git for beginners
Arulmurugan Rajaraman
 
PDF
Git in Eclipse
Dariusz Łuksza
 
PPTX
Version controll.pptx
Md. Main Uddin Rony
 
PDF
Intro to Git and GitHub
Matthew McCullough
 
PDF
Git Tutorial I
Jim Yeh
 
Version Control System - Git
Carlo Bernaschina
 
Git in 10 minutes
Safique Ahmed Faruque
 
Git advanced
Peter Vandenabeele
 
Advanced Git Presentation By Swawibe
Md Swawibe Ul Alam
 
Introduction to git and github
Aderemi Dadepo
 
Git introduction
satyendrajaladi
 
GIT | Distributed Version Control System
Mohammad Imam Hossain
 
Git 101
jayrparro
 
From svn to git
Nehal Shah
 
Git tutorial
Pham Quy (Jack)
 
What the Git? - WordCamp Atlanta
Nathaniel Schweinberg
 
Git training with Devaamo
Otto Kekäläinen
 
Extra bit with git
gdgjss
 
The everyday developer's guide to version control with Git
E Carter
 
Version control
Giovanni Marco Dall'Olio
 
Git for beginners
Arulmurugan Rajaraman
 
Git in Eclipse
Dariusz Łuksza
 
Version controll.pptx
Md. Main Uddin Rony
 
Intro to Git and GitHub
Matthew McCullough
 
Git Tutorial I
Jim Yeh
 

Viewers also liked (6)

PPT
Google apps
Nigel Gibson
 
PPT
06 Php Mysql Connect Query
Geshan Manandhar
 
PPT
07 Php Mysql Update Delete
Geshan Manandhar
 
PPT
Technology at tutorials
Nigel Gibson
 
PPTX
Business Rules Logical Experssion and SBVR
Geshan Manandhar
 
PDF
Embrace chatops, stop installing deployment software - Laracon EU 2016
Geshan Manandhar
 
Google apps
Nigel Gibson
 
06 Php Mysql Connect Query
Geshan Manandhar
 
07 Php Mysql Update Delete
Geshan Manandhar
 
Technology at tutorials
Nigel Gibson
 
Business Rules Logical Experssion and SBVR
Geshan Manandhar
 
Embrace chatops, stop installing deployment software - Laracon EU 2016
Geshan Manandhar
 
Ad

Similar to Git intro hands on windows with msysgit (20)

PPTX
Setting up Git.pptx
tapanvyas11
 
PPTX
1-Intro to VC & GIT PDF.pptx
HuthaifaAlmaqrami1
 
PDF
Github and Git What the fuck is this shit .pdf
krishna50blogging
 
PPTX
Git and Github
Teodora Ahkozidou
 
PDF
Git
Terry Wang
 
PDF
Git 入门与实践
Terry Wang
 
PPT
GIT By Sivakrishna
Nyros Technologies
 
PPTX
Git and github
Teodora Ahkozidou
 
PDF
Git 入门 与 实践
Terry Wang
 
PPT
git2nvlkndvslnvdslnlknvdlnlvdsnlknsdvlkn.ppt
loleto7559
 
ODP
Introduction to Git
Amit Mathur
 
PPTX
Git and Github.pptx
Hitesh670643
 
PPT
Git and GitHUB Explanation and simple coding for CLI
kumaresan7751
 
PPTX
Introduction to git and Github
Wycliff1
 
PPTX
git github PPT_GDSCIIITK.pptx
AbelPhilipJoseph
 
PPTX
Git & Github
Aman Lalpuria
 
PPTX
Git Basics
Ryan Condron
 
PPT
git2.ppt
ssusered2ec2
 
PDF
Introducing Git and git flow
Sebin Benjamin
 
Setting up Git.pptx
tapanvyas11
 
1-Intro to VC & GIT PDF.pptx
HuthaifaAlmaqrami1
 
Github and Git What the fuck is this shit .pdf
krishna50blogging
 
Git and Github
Teodora Ahkozidou
 
Git 入门与实践
Terry Wang
 
GIT By Sivakrishna
Nyros Technologies
 
Git and github
Teodora Ahkozidou
 
Git 入门 与 实践
Terry Wang
 
git2nvlkndvslnvdslnlknvdlnlvdsnlknsdvlkn.ppt
loleto7559
 
Introduction to Git
Amit Mathur
 
Git and Github.pptx
Hitesh670643
 
Git and GitHUB Explanation and simple coding for CLI
kumaresan7751
 
Introduction to git and Github
Wycliff1
 
git github PPT_GDSCIIITK.pptx
AbelPhilipJoseph
 
Git & Github
Aman Lalpuria
 
Git Basics
Ryan Condron
 
git2.ppt
ssusered2ec2
 
Introducing Git and git flow
Sebin Benjamin
 
Ad

More from Geshan Manandhar (20)

PDF
How to build an image to geo location guesser using Gemini 2 - Canberra.pdf
Geshan Manandhar
 
PDF
build-with-ai-sydney AI for web devs Tamas Piros
Geshan Manandhar
 
PDF
Are logs a software engineer’s best friend? Yes -- follow these best practices
Geshan Manandhar
 
PDF
We lost $ 20.5K in one day and how we could have saved it… hint: better autom...
Geshan Manandhar
 
PDF
Moving from A and B to 150 microservices, the journey, and learnings
Geshan Manandhar
 
PDF
Adopt a painless continuous delivery culture, add more business value
Geshan Manandhar
 
PDF
Things i wished i knew as a junior developer
Geshan Manandhar
 
PDF
Do You Git Your Code? Follow Simplified Gitflow Branching Model to Improve Pr...
Geshan Manandhar
 
PDF
Embrace chatOps, stop installing deployment software
Geshan Manandhar
 
PDF
7 rules of simple and maintainable code
Geshan Manandhar
 
PDF
Software engineering In Nepal mid 2015 part 01
Geshan Manandhar
 
PDF
A simplified Gitflow
Geshan Manandhar
 
PDF
How to become a better software company technically
Geshan Manandhar
 
PDF
Things I wished I knew while doing my tech bachelor / undergraduate
Geshan Manandhar
 
PDF
Message Queues a basic overview
Geshan Manandhar
 
PDF
Most popular brands, people on facebook in nepal as of 2013 q4
Geshan Manandhar
 
PDF
Drupal 7 basic setup and contrib modules for a brochure website
Geshan Manandhar
 
ODP
Drupal 7 install with modules and themes
Geshan Manandhar
 
ODP
Drupal introduction
Geshan Manandhar
 
PPTX
No sql
Geshan Manandhar
 
How to build an image to geo location guesser using Gemini 2 - Canberra.pdf
Geshan Manandhar
 
build-with-ai-sydney AI for web devs Tamas Piros
Geshan Manandhar
 
Are logs a software engineer’s best friend? Yes -- follow these best practices
Geshan Manandhar
 
We lost $ 20.5K in one day and how we could have saved it… hint: better autom...
Geshan Manandhar
 
Moving from A and B to 150 microservices, the journey, and learnings
Geshan Manandhar
 
Adopt a painless continuous delivery culture, add more business value
Geshan Manandhar
 
Things i wished i knew as a junior developer
Geshan Manandhar
 
Do You Git Your Code? Follow Simplified Gitflow Branching Model to Improve Pr...
Geshan Manandhar
 
Embrace chatOps, stop installing deployment software
Geshan Manandhar
 
7 rules of simple and maintainable code
Geshan Manandhar
 
Software engineering In Nepal mid 2015 part 01
Geshan Manandhar
 
A simplified Gitflow
Geshan Manandhar
 
How to become a better software company technically
Geshan Manandhar
 
Things I wished I knew while doing my tech bachelor / undergraduate
Geshan Manandhar
 
Message Queues a basic overview
Geshan Manandhar
 
Most popular brands, people on facebook in nepal as of 2013 q4
Geshan Manandhar
 
Drupal 7 basic setup and contrib modules for a brochure website
Geshan Manandhar
 
Drupal 7 install with modules and themes
Geshan Manandhar
 
Drupal introduction
Geshan Manandhar
 

Recently uploaded (20)

PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 

Git intro hands on windows with msysgit

  • 1. GIT Intro and usage on Windows - Basic By Geshan Manandhar http://geshan.blogspot.com 1http://geshan.blogspot.com
  • 2. Agenda  What is git  Who uses it, features  How to use git on windows  Prepare working directory  Create public repository  Add, commit, pull, push  Git ignore  Other commands and things to look at http://geshan.blogspot.com 2
  • 3. GIT is  a free & open source, distributed version control system.  designed to handle everything from small to very large projects with speed and efficiency.  a developer’s friend in a multi developer environment.  a must tool to go back in history to what you coded and see the code changes made in the timeline. 3http://geshan.blogspot.com
  • 4. Who uses GIT  Many big names including ◦ Linux/Kernel ◦ Eclipse ◦ Ruby on Rails ◦ Android ◦ PostgreSQL ◦ Git itself. 4http://geshan.blogspot.com
  • 5. Why use Git/ Features  Fast  Distributed (no central repository)  Can work offline  Small (file system usage)  Has a staging area  Access control (with gitosis)  Fit for any project size  Branching, tags …  GitHub.com ◦ Reference: http://whygitisbetterthanx.com 5http://geshan.blogspot.com
  • 6. Distributed??  No Central repository  All developers have a working copy and own private repo (.git)  Code transfer should be done on non-private repo. http://geshan.blogspot.com 6 Image Source: http://coding.smashingmagazine.c om/2011/07/26/modern-version- control-with-git-series/
  • 7. How to use on windows?  Could not find mature GUI tools like tortoise SVN.  Integrated in Eclipse (with plugin) and NetBeans (good colorful support).  If you are programmer, you are not scared of the command line so:  Download MsysGit : http://code.google.com/p/msysgit/dow nloads/list http://geshan.blogspot.com 7
  • 8. MsysGit for git on Windows http://geshan.blogspot.com 8 Steps: 1. Download the exe file (or the portable one, it will not need installation). 2. Install msysgit , next … next is your friend here with finish – no need of any fancy configuration. 3. Run the git bash application.
  • 9. Git bash part of MsysGit http://geshan.blogspot.com 9
  • 10. User and line settings for win  If you are familiar with ~ of unix systems this might be easy.  Make sure where your home dir is in your windows setup like: ◦ /c/users/Geshan – for me in Windows 7  Set ~/.bash_profile if you want.(google bash profiles and dot files, if you want to)  Run this: git config --global core.autocrlf true  Have a look for new line setting if need be: http://github.com/guides/dealing-with-newlines-in-git http://geshan.blogspot.com 10
  • 11. Introduce yourself to GIT  execute commands in bash ◦ git config --global user.name <name> ◦ git config --global user.email <email> ◦ (this gets written to your ~/.gitconfig file)  Example ◦ git config --global user.name “Geshan Manadhar” ◦ git config --global user.email “[email protected]” http://geshan.blogspot.com 11
  • 12. Some conceptual clarity  You have a working directory and your private repo (a .git folder in your dir)  You always push your changes and pull changes from another non-private repository. http://geshan.blogspot.com 12 Working Dir with git Public git repo on file system
  • 13. Preparing your working dir http://geshan.blogspot.com 13 Nothing significant just created a directory with a file that’s it.
  • 14. Preparing working dir 2 http://geshan.blogspot.com 14
  • 15. Working directory made  Commands used ◦ git init ; to initialize the current dir for git tracking. ◦ git status; shows current status ◦ git add; put files to stating area  Variations like  Git add . ; . Is for all changed files  Git add /path/to/file ; /c/dir1/file1.txt  Git add /path/a.*  etc http://geshan.blogspot.com 15
  • 16. First commit http://geshan.blogspot.com 16 git commit –m “message”; Files have been put into the local repository (the .git dir created with git init) All things are in local so we need to push things to a non- private repository. For this example I’ll create a local repository. Always remember to write concise but meaningful commit messages.
  • 17. Creating public repository http://geshan.blogspot.com 17 A bare passive public repo has been created for pushing code. Remember the path is /c/users/geshan/gitrepos/testgit.git Different command : git init --bare; Now we will link the working directory with this public repo.
  • 18. Linking working dir with public repo http://geshan.blogspot.com 18 Remote repository created in previous slide linked to the working directory. git remote add <name> <path> Path can be: File : /home/geshan/gitrepost/testrepo.git Remote file: ssh://[email protected]/home/user1/gitrepos/test.git Gitosis: [email protected]:test.git
  • 19. First push to remote repo  git push <repo_name> <branch_name>  Repo_name is just a alias to the path.  git push origin master ◦ Default repo when cloned in origin and default branch is master. http://geshan.blogspot.com 19
  • 20. First pull attempt  Pull is done to get the changes done by others in the self working directory.  git pull <repo_name> <branch_name>  git pull origin master http://geshan.blogspot.com 20
  • 21. .gitignore file  .gitignore file is generally placed in the root of the working directory.  As the name suggests it can ignore certain files from git.  Generally local config is ignored but a back up is kept for others, example database username password config. http://geshan.blogspot.com 21
  • 23. Continue to push bkp file http://geshan.blogspot.com 23
  • 24. Pull by a new developer http://geshan.blogspot.com 24 A new developer will generally clone the project, than create new files. -Notice git remote –v Git branch shows available branches.
  • 25. Scenario dev 2 posts code  Dev 2 changed test.txt and pushed his code to public repo. http://geshan.blogspot.com 25
  • 26. Dev 1 pulled the changes.  Dev 1 can immediately have the changed code. http://geshan.blogspot.com 26
  • 27. Gitk to know what changed  execute gitk on a git repo root to get this. http://geshan.blogspot.com 27
  • 28. Other git commands  git log  git short log –sne  git checkout / git branch –b newbranch  git tag v 1.0 –a “test”  git fsck  git push dev feature1; - testing you. http://geshan.blogspot.com 28
  • 29. Things to look at  Reset the code to old version  Branching with git  Tagging with git  How to handle conflict situation  Other git features and commands  Check out the git cheat sheet: http://www.cheat-sheets.org/saved- copy/git-cheat-sheet.pdf  For details of hashing etc check the git internals book. http://geshan.blogspot.com 29
  • 30. Happy Git-ing  Google git  See videos on youtube  Find some good podcasts on git  You will like what you use http://geshan.blogspot.com 30