SlideShare a Scribd company logo
“lets talk solution”
1
GIT Workflow
Getting Started
Downloading git
Download the software - it's free http://git-scm.com/downloads
or on Mac (homebrew), $ brew install git
Git
FIRST STEP
Check installation
- Check if Git is installed:
$ git --version
git version 1.7.10.2 (Apple Git-33)
- If not, brew install git or download the installer
- Set your Git username and email to your global config: $ git config --global
user.name "Geoff Hoffman"
$ git config --global user.email "phpguru@salientdigital.com"
– Creating a repository (if one does not exist remotely): $ git init
 @see http://git-scm.com/docs/git-init
– Or, cloning a remote repository:
 $ git clone https://reposite.tld/account/repo.git localdir
 $ git clone https://github.com/phpguru/phpredis.git
– localdir is optional. The repo name is used in this case.
– @see http://git-scm.com/docs/git-clone
 $ cd phpredis $ls-la
Obtaining a repository
Inspecting your repo
– Change Directory into the repository & issue a git status
 $ cd path/to/repo
 $ git status
– @see http://git-scm.com/docs/git-status
 "Displays paths that have differences between the index file and the current
HEAD commit, paths that have differences between the working tree and the
index file, and paths in the working tree that are not tracked by Git (and are not
ignored by gitignore(5))"
– @see http://git-scm.com/docs/gitignore
– In other words, shows what you added, modified or deleted since your last
commit.
Inspecting your repo
– Change Directory into the repository & issue a git log
 $ cd path/to/repo
 $ git log
 $ git log --pretty=oneline
 $gitlog-1
– @see http://git-scm.com/docs/git-log
– "Shows the commit logs.“
– In other words, why you committed something
 Hopefully you wrote descriptive commit messages in the past!
Making Edits & Committing
 You can use whatever program you normally use to edit files.
 Make a new file - newfile.txt
 Edit the file as desired
 Save it in your working directory
 $ git status
– will show the file as "Changes not staged for commit"
 $ git add newfile.txt
 $ git status
– will show newfile.txt as "Changes to be committed"
– git commit -m "Added newfile.txt as an example"
» [Master 1e77a20] Added newfile.txt as an example
 1 file changed, 0 insertions(+), 0 deletions(-)
Adding (staging) changes
 – Change Directory into the repository & issue a git status, then add
new/modified files
 $ cd path/to/repo
 $ git add (file)
 $gitadd–A
 – @see http://git-scm.com/docs/git-add
 "This command updates the index using the current content found in the
working tree, to prepare the content staged for the next commit."
 In other words, stage your added, modified or deleted files for committing.
Committing (staged) changes
– Change Directory into the repository & issue a git status, then add new/modified
files, then commit them to your local repository
 $ cd path/to/repo
 $ git add (file)
 $ git commit -m "What did you change? Log messages matter." – @see
http://git-scm.com/docs/git-commit
 "Stores the current contents of the index in a new commit along with a log
message from the user describing the changes."
 In other words, store the added, modified or deleted files you staged in your
repository.
Git
Pushing
At this point, none of those changes you've made have left your computer. (You still
have local "infinite undo".) Let's push those changes to the remote repo.
 git push <repository> <refspec> • git push origin master
 git push origin master:master
– You now have an annotated, offsite backup of the work you performed!
 REMEMBER:
– If you never commit, you have no history.
– If you never push, you have no offsite backup.
 As a rule of thumb, commit every hour, push every day.
– There is no reason not to commit after every "logical stopping-point" and push
when a good section of work is complete, unit tests pass, etc.
 After you commit, your colleagues can pull changes down from the origin
repository to their local working repository.
Pushing your changes offsite (local -> remote)
– Change Directory into the repository & issue a git push
 $ cd path/to/repo
 $ git push origin master
– @see http://git-scm.com/docs/git-push
 "Updates remote refs using local refs, while sending objects necessary to
complete the given refs."
 In other words, send your local changes back to the remote repo you cloned
from.
Pulling someone else's changes (remote -> local)
– Change Directory into the repository & issue a git pull
$ cd path/to/repo
$ git pull origin master
– @see http://git-scm.com/docs/git-pull
 "Incorporates changes from a remote repository into the current branch. In its
default mode, git pull is shorthand for git fetch followed by git merge
FETCH_HEAD."
 In other words, retrieve changes made to the remote repo and merge them into
your local repo, updating your working copy to match.
Git
NEXT STEP
Working smart(er)
– Merge changes made in a feature branch into another branch, typically
development, to then be tested, and ultimately merged to the master branch and
tagged.
$ cd path/to/repo
$ git branch
$ git checkout master
$ git merge featurename
– @see http://git-scm.com/docs/git-merge
"Incorporates changes from the named commits (since the time their histories
diverged from the current branch) into the current branch. This command is used
by git pull to incorporate changes from another repository and can be used by
hand to merge changes from one branch into another."
In other words, apply changes from another branch to the current one.
Wrap Up: Review
The most common commands you will use during a normal day/week working with Git to manage
versions of code:
Download/Create a local repo $ git clone
$ git init
Checking what's changed $ git status
$ git log
Storing edits $ git add
$ git commit
Updating your local repo $ git pull (git fetch)
$ git branch
$ git merge
Storing changes offsite/offbox $ git commit
$ git push
Storing changes offsite/offbox $ git tag
$ git push
GOAL
To learn to resolve merging conflicts
Merge the master branch with style
Let us go back to the style branch and merge it with a new master branch.
RUN:
git checkout style
git merge master
RESULT:
$ git checkout style
Switched to branch 'style'
$ git merge master
Auto-merging lib/hello.html
CONFLICT (content): Merge conflict in lib/hello.html
Automatic merge failed; fix conflicts and then commit the result.
If you open the lib/hello.html you will see:
FILE: LIB/HELLO.HTML
<!-- Author: Alexander Shvets (alex@githowto.com) -->
<html>
<head>
<<<<<<< HEAD
<link type="text/css" rel="stylesheet" media="all" href="style.css" />
=======
<!-- no style -->
>>>>>>> master
</head>
<body> <h1>Hello,World! Life is great!</h1>
</body>
</html>
The first section is the version of the current branch (style) head. The second
section is the version of master branch.
Resolution of the conflict
• You need to resolve the conflict manually. Make changes to lib/hello.html to
achieve the following result.
FILE: LIB/HELLO.HTML
<!-- Author: Alexander Shvets (alex@githowto.com) -->
<html>
<head>
<link type="text/css" rel="stylesheet" media="all" href="style.css" />
</head>
<body>
<h1>Hello, World! Life is great!</h1>
</body>
</html>
Make a commit of conflict resolution
• RUN:
git add lib/hello.html
git commit -m "Merged master fixed conflict."
• RESULT:
$ git add lib/hello.html
$ git commit -m "Merged master fixed conflict."
Recorded resolution for 'lib/hello.html'.
[style 645c4e6] Merged master fixed conflict.
Git
26
CONTACT US add.websolution
contact@addwebsolution.comPut us to work
“lets talk solution”

More Related Content

PDF
Version Control with Git for Beginners
bryanbibat
 
PPT
Learn Git Basics
Prakash Dantuluri
 
PDF
Git Basics (Professionals)
bryanbibat
 
PPT
390a gitintro 12au
Nguyen Van Hung
 
PDF
Git: basic to advanced
Yodalee
 
PDF
Git Real
Gong Haibing
 
PDF
Git for the absolute beginners
Gabriele Baldassarre
 
PDF
Git - Get Ready To Use It
Daniel Kummer
 
Version Control with Git for Beginners
bryanbibat
 
Learn Git Basics
Prakash Dantuluri
 
Git Basics (Professionals)
bryanbibat
 
390a gitintro 12au
Nguyen Van Hung
 
Git: basic to advanced
Yodalee
 
Git Real
Gong Haibing
 
Git for the absolute beginners
Gabriele Baldassarre
 
Git - Get Ready To Use It
Daniel Kummer
 

What's hot (20)

DOCX
Git github
Anurag Deb
 
ODP
The Fundamentals of Git
DivineOmega
 
PPTX
Git-ing out of your git messes
Katie Sylor-Miller
 
PDF
My Notes from https://www.codeschool.com/courses/git-real
Eneldo Serrata
 
PDF
Git is my hero
Selena Deckelmann
 
KEY
Git Basics at Rails Underground
Ariejan de Vroom
 
PDF
Git real slides
Lucas Couto
 
PPTX
Git for beginner
Trung Huynh
 
KEY
Basic Git
Knut Haugen
 
KEY
Gittalk
prtinsley
 
PPTX
Introduction To Git Workshop
themystic_ca
 
KEY
Matt Gauger - Git & Github web414 December 2010
Matt Gauger
 
PDF
Git-ing out of your git messes - Fluent Conf 2017
Katie Sylor-Miller
 
PPT
Git Atlrug
Jason Noble
 
PPTX
Git and GitHub
Md. Ahsan Habib Nayan
 
PPTX
Intro to Git DevOps Tally Presentation 101615
Brian K. Vagnini
 
PPT
Git Cards - Keynote Format
Adam Lowe
 
PDF
Git SCM
Stefan Prutianu
 
PDF
Introducción a git y GitHub
Lucas Videla
 
PPTX
Git like a pro EDD18 - Full edition
Jesús Miguel Benito Calzada
 
Git github
Anurag Deb
 
The Fundamentals of Git
DivineOmega
 
Git-ing out of your git messes
Katie Sylor-Miller
 
My Notes from https://www.codeschool.com/courses/git-real
Eneldo Serrata
 
Git is my hero
Selena Deckelmann
 
Git Basics at Rails Underground
Ariejan de Vroom
 
Git real slides
Lucas Couto
 
Git for beginner
Trung Huynh
 
Basic Git
Knut Haugen
 
Gittalk
prtinsley
 
Introduction To Git Workshop
themystic_ca
 
Matt Gauger - Git & Github web414 December 2010
Matt Gauger
 
Git-ing out of your git messes - Fluent Conf 2017
Katie Sylor-Miller
 
Git Atlrug
Jason Noble
 
Git and GitHub
Md. Ahsan Habib Nayan
 
Intro to Git DevOps Tally Presentation 101615
Brian K. Vagnini
 
Git Cards - Keynote Format
Adam Lowe
 
Introducción a git y GitHub
Lucas Videla
 
Git like a pro EDD18 - Full edition
Jesús Miguel Benito Calzada
 
Ad

Viewers also liked (20)

ODP
Android tutorials2 android_tools_on_eclipse
Vlad Kolesnyk
 
PPT
68788 health care reform health plans overview 2 14-13
Jerry Whitaker CIC,CRIS
 
PPTX
Foodcombining visuals
Missdip24
 
PPTX
Doing things with manuscripts: CLIR post doc-seminar, Bryn Mawr College 7.31....
SNichols4
 
PPT
Trendifythis.com
TrendifyThis
 
PPTX
Communication
AddWeb Solution Pvt. Ltd.
 
PPTX
Uniforme scolare
Hainute copii Johnny Prodcomimpex
 
ODP
Android tutorials7 calculator_packageexploirer
Vlad Kolesnyk
 
DOCX
Teks Forum Hegemoni
Sherly Jewinly
 
PPTX
копия три слагаемых успешного урока английского языка
svetopusha
 
DOC
Atul Shende_Final CV
Atul Shende
 
PPT
Nota Tajuk 2 evolusi perkembangan PTV
Sherly Jewinly
 
DOC
Benefits 101 guide
Jerry Whitaker CIC,CRIS
 
ODP
Github tutorial1
Vlad Kolesnyk
 
PDF
Clink for Card Issuers
Roshan Gummalla
 
PPT
видеоэкскурсия в красный берег(полная)
svetopusha
 
PPTX
Услуги стадиона «Динамо»
Andrey Pantiukhov
 
PPTX
The asian section collections final
Asiansection
 
PPTX
Brief about outsourcing
AddWeb Solution Pvt. Ltd.
 
Android tutorials2 android_tools_on_eclipse
Vlad Kolesnyk
 
68788 health care reform health plans overview 2 14-13
Jerry Whitaker CIC,CRIS
 
Foodcombining visuals
Missdip24
 
Doing things with manuscripts: CLIR post doc-seminar, Bryn Mawr College 7.31....
SNichols4
 
Trendifythis.com
TrendifyThis
 
Android tutorials7 calculator_packageexploirer
Vlad Kolesnyk
 
Teks Forum Hegemoni
Sherly Jewinly
 
копия три слагаемых успешного урока английского языка
svetopusha
 
Atul Shende_Final CV
Atul Shende
 
Nota Tajuk 2 evolusi perkembangan PTV
Sherly Jewinly
 
Benefits 101 guide
Jerry Whitaker CIC,CRIS
 
Github tutorial1
Vlad Kolesnyk
 
Clink for Card Issuers
Roshan Gummalla
 
видеоэкскурсия в красный берег(полная)
svetopusha
 
Услуги стадиона «Динамо»
Andrey Pantiukhov
 
The asian section collections final
Asiansection
 
Brief about outsourcing
AddWeb Solution Pvt. Ltd.
 
Ad

Similar to Git (20)

PDF
Git and github 101
Senthilkumar Gopal
 
PPTX
Git and github introduction
John(Qiang) Zhang
 
PDF
A Quick Start - Version Control with Git
Dmitry Sheiko
 
PPTX
sample.pptx
UshaSuray
 
PPTX
Understanding about git
Sothearin Ren
 
PPTX
Git session Dropsolid.com
dropsolid
 
PPTX
Git and Github
Teodora Ahkozidou
 
KEY
Git Distributed Version Control System
Victor Wong
 
PPTX
Git and github
Teodora Ahkozidou
 
PDF
Git Concepts, Commands and Connectivity
Raja Soundaramourty
 
PDF
Git cheatsheet
Weghlis Azzariou
 
PDF
Git the Docs: A fun, hands-on introduction to version control
Becky Todd
 
PPTX
Hacktoberfest intro to Git and GitHub
DSC GVP
 
DOCX
GitSetupLinux
Shubham Verma
 
DOCX
Git setuplinux
Shubham Verma
 
PPT
Git 101 - Crash Course in Version Control using Git
Geoff Hoffman
 
PDF
Getting some Git
BADR
 
PDF
Loading...git
Rafael García
 
PDF
Git_real_slides
Khanh NL-bantoilatoi
 
Git and github 101
Senthilkumar Gopal
 
Git and github introduction
John(Qiang) Zhang
 
A Quick Start - Version Control with Git
Dmitry Sheiko
 
sample.pptx
UshaSuray
 
Understanding about git
Sothearin Ren
 
Git session Dropsolid.com
dropsolid
 
Git and Github
Teodora Ahkozidou
 
Git Distributed Version Control System
Victor Wong
 
Git and github
Teodora Ahkozidou
 
Git Concepts, Commands and Connectivity
Raja Soundaramourty
 
Git cheatsheet
Weghlis Azzariou
 
Git the Docs: A fun, hands-on introduction to version control
Becky Todd
 
Hacktoberfest intro to Git and GitHub
DSC GVP
 
GitSetupLinux
Shubham Verma
 
Git setuplinux
Shubham Verma
 
Git 101 - Crash Course in Version Control using Git
Geoff Hoffman
 
Getting some Git
BADR
 
Loading...git
Rafael García
 
Git_real_slides
Khanh NL-bantoilatoi
 

More from AddWeb Solution Pvt. Ltd. (20)

PPTX
Best WP Engine Alternatives: Top 10 WordPress Hosting Solutions
AddWeb Solution Pvt. Ltd.
 
PDF
Ultimate Guide to Maximize Success with UI/UX Design Services
AddWeb Solution Pvt. Ltd.
 
PPTX
14 UX-UI Design Tips For Your Next Project.pptx
AddWeb Solution Pvt. Ltd.
 
PPTX
Hubspot Vs Drupal – Choosing the Right CMS for Your Business.pptx
AddWeb Solution Pvt. Ltd.
 
PDF
Code Testing - Know Different Types of Testing and Benefits for Software Deve...
AddWeb Solution Pvt. Ltd.
 
PDF
Advantages of Server-side Rendering (SSR) in Vue.js Development
AddWeb Solution Pvt. Ltd.
 
PDF
A Brief About AddWeb Solution's Services
AddWeb Solution Pvt. Ltd.
 
PDF
Top SaaS Frameworks for Software Product Development.pdf
AddWeb Solution Pvt. Ltd.
 
PDF
The Ultimate Step-by-Step Guide to Develop a Calendar App.pdf
AddWeb Solution Pvt. Ltd.
 
PDF
Top Exclusive Mobile App Ideas for Real Estate Businesses.pdf
AddWeb Solution Pvt. Ltd.
 
PDF
How to Start A Food Delivery Business Like DoorDash in 2024.pdf
AddWeb Solution Pvt. Ltd.
 
PDF
Choosing the Right Node.js Framework For App Development 2024.pdf
AddWeb Solution Pvt. Ltd.
 
PDF
The Complete Guide to Serverless Computing.pdf
AddWeb Solution Pvt. Ltd.
 
PDF
How to Implement Content Marketing for Ecommerce SEO.pdf
AddWeb Solution Pvt. Ltd.
 
PDF
Why Use Vue JS The Ultimate Guide for Frontend Every Aspect Covered.pdf
AddWeb Solution Pvt. Ltd.
 
PDF
Everything to Know About Custom Healthcare App Development.pdf
AddWeb Solution Pvt. Ltd.
 
PDF
How Much Does It Cost to Build a React Native App in 2024.pdf
AddWeb Solution Pvt. Ltd.
 
PDF
How Much Does HR & Staffing Software Development Cost.pdf
AddWeb Solution Pvt. Ltd.
 
PDF
Guide to Developing a Cloud Based SaaS App
AddWeb Solution Pvt. Ltd.
 
PDF
Why Choose Drupal As Your Restaurant CMS In 2024.pdf
AddWeb Solution Pvt. Ltd.
 
Best WP Engine Alternatives: Top 10 WordPress Hosting Solutions
AddWeb Solution Pvt. Ltd.
 
Ultimate Guide to Maximize Success with UI/UX Design Services
AddWeb Solution Pvt. Ltd.
 
14 UX-UI Design Tips For Your Next Project.pptx
AddWeb Solution Pvt. Ltd.
 
Hubspot Vs Drupal – Choosing the Right CMS for Your Business.pptx
AddWeb Solution Pvt. Ltd.
 
Code Testing - Know Different Types of Testing and Benefits for Software Deve...
AddWeb Solution Pvt. Ltd.
 
Advantages of Server-side Rendering (SSR) in Vue.js Development
AddWeb Solution Pvt. Ltd.
 
A Brief About AddWeb Solution's Services
AddWeb Solution Pvt. Ltd.
 
Top SaaS Frameworks for Software Product Development.pdf
AddWeb Solution Pvt. Ltd.
 
The Ultimate Step-by-Step Guide to Develop a Calendar App.pdf
AddWeb Solution Pvt. Ltd.
 
Top Exclusive Mobile App Ideas for Real Estate Businesses.pdf
AddWeb Solution Pvt. Ltd.
 
How to Start A Food Delivery Business Like DoorDash in 2024.pdf
AddWeb Solution Pvt. Ltd.
 
Choosing the Right Node.js Framework For App Development 2024.pdf
AddWeb Solution Pvt. Ltd.
 
The Complete Guide to Serverless Computing.pdf
AddWeb Solution Pvt. Ltd.
 
How to Implement Content Marketing for Ecommerce SEO.pdf
AddWeb Solution Pvt. Ltd.
 
Why Use Vue JS The Ultimate Guide for Frontend Every Aspect Covered.pdf
AddWeb Solution Pvt. Ltd.
 
Everything to Know About Custom Healthcare App Development.pdf
AddWeb Solution Pvt. Ltd.
 
How Much Does It Cost to Build a React Native App in 2024.pdf
AddWeb Solution Pvt. Ltd.
 
How Much Does HR & Staffing Software Development Cost.pdf
AddWeb Solution Pvt. Ltd.
 
Guide to Developing a Cloud Based SaaS App
AddWeb Solution Pvt. Ltd.
 
Why Choose Drupal As Your Restaurant CMS In 2024.pdf
AddWeb Solution Pvt. Ltd.
 

Recently uploaded (20)

PPTX
Visualising Data with Scatterplots in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
What to consider before purchasing Microsoft 365 Business Premium_PDF.pdf
Q-Advise
 
PPTX
Role Of Python In Programing Language.pptx
jaykoshti048
 
PPTX
Presentation about variables and constant.pptx
safalsingh810
 
PDF
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
PPTX
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
PDF
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
PPTX
The-Dawn-of-AI-Reshaping-Our-World.pptxx
parthbhanushali307
 
PPTX
Explanation about Structures in C language.pptx
Veeral Rathod
 
PDF
Bandai Playdia The Book - David Glotz
BluePanther6
 
PDF
10 posting ideas for community engagement with AI prompts
Pankaj Taneja
 
PPTX
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
PPTX
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
PPTX
Can You Build Dashboards Using Open Source Visualization Tool.pptx
Varsha Nayak
 
PPT
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
PDF
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
PPTX
ConcordeApp: Engineering Global Impact & Unlocking Billions in Event ROI with AI
chastechaste14
 
PDF
Immersive experiences: what Pharo users do!
ESUG
 
PPTX
Odoo Integration Services by Candidroot Solutions
CandidRoot Solutions Private Limited
 
PDF
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 
Visualising Data with Scatterplots in IBM SPSS Statistics.pptx
Version 1 Analytics
 
What to consider before purchasing Microsoft 365 Business Premium_PDF.pdf
Q-Advise
 
Role Of Python In Programing Language.pptx
jaykoshti048
 
Presentation about variables and constant.pptx
safalsingh810
 
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
The-Dawn-of-AI-Reshaping-Our-World.pptxx
parthbhanushali307
 
Explanation about Structures in C language.pptx
Veeral Rathod
 
Bandai Playdia The Book - David Glotz
BluePanther6
 
10 posting ideas for community engagement with AI prompts
Pankaj Taneja
 
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
Can You Build Dashboards Using Open Source Visualization Tool.pptx
Varsha Nayak
 
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
ConcordeApp: Engineering Global Impact & Unlocking Billions in Event ROI with AI
chastechaste14
 
Immersive experiences: what Pharo users do!
ESUG
 
Odoo Integration Services by Candidroot Solutions
CandidRoot Solutions Private Limited
 
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 

Git

  • 2. Getting Started Downloading git Download the software - it's free http://git-scm.com/downloads or on Mac (homebrew), $ brew install git
  • 5. Check installation - Check if Git is installed: $ git --version git version 1.7.10.2 (Apple Git-33) - If not, brew install git or download the installer - Set your Git username and email to your global config: $ git config --global user.name "Geoff Hoffman" $ git config --global user.email "[email protected]"
  • 6. – Creating a repository (if one does not exist remotely): $ git init  @see http://git-scm.com/docs/git-init – Or, cloning a remote repository:  $ git clone https://reposite.tld/account/repo.git localdir  $ git clone https://github.com/phpguru/phpredis.git – localdir is optional. The repo name is used in this case. – @see http://git-scm.com/docs/git-clone  $ cd phpredis $ls-la Obtaining a repository
  • 7. Inspecting your repo – Change Directory into the repository & issue a git status  $ cd path/to/repo  $ git status – @see http://git-scm.com/docs/git-status  "Displays paths that have differences between the index file and the current HEAD commit, paths that have differences between the working tree and the index file, and paths in the working tree that are not tracked by Git (and are not ignored by gitignore(5))" – @see http://git-scm.com/docs/gitignore – In other words, shows what you added, modified or deleted since your last commit.
  • 8. Inspecting your repo – Change Directory into the repository & issue a git log  $ cd path/to/repo  $ git log  $ git log --pretty=oneline  $gitlog-1 – @see http://git-scm.com/docs/git-log – "Shows the commit logs.“ – In other words, why you committed something  Hopefully you wrote descriptive commit messages in the past!
  • 9. Making Edits & Committing  You can use whatever program you normally use to edit files.  Make a new file - newfile.txt  Edit the file as desired  Save it in your working directory  $ git status – will show the file as "Changes not staged for commit"  $ git add newfile.txt  $ git status – will show newfile.txt as "Changes to be committed" – git commit -m "Added newfile.txt as an example" » [Master 1e77a20] Added newfile.txt as an example  1 file changed, 0 insertions(+), 0 deletions(-)
  • 10. Adding (staging) changes  – Change Directory into the repository & issue a git status, then add new/modified files  $ cd path/to/repo  $ git add (file)  $gitadd–A  – @see http://git-scm.com/docs/git-add  "This command updates the index using the current content found in the working tree, to prepare the content staged for the next commit."  In other words, stage your added, modified or deleted files for committing.
  • 11. Committing (staged) changes – Change Directory into the repository & issue a git status, then add new/modified files, then commit them to your local repository  $ cd path/to/repo  $ git add (file)  $ git commit -m "What did you change? Log messages matter." – @see http://git-scm.com/docs/git-commit  "Stores the current contents of the index in a new commit along with a log message from the user describing the changes."  In other words, store the added, modified or deleted files you staged in your repository.
  • 13. Pushing At this point, none of those changes you've made have left your computer. (You still have local "infinite undo".) Let's push those changes to the remote repo.  git push <repository> <refspec> • git push origin master  git push origin master:master – You now have an annotated, offsite backup of the work you performed!  REMEMBER: – If you never commit, you have no history. – If you never push, you have no offsite backup.  As a rule of thumb, commit every hour, push every day. – There is no reason not to commit after every "logical stopping-point" and push when a good section of work is complete, unit tests pass, etc.  After you commit, your colleagues can pull changes down from the origin repository to their local working repository.
  • 14. Pushing your changes offsite (local -> remote) – Change Directory into the repository & issue a git push  $ cd path/to/repo  $ git push origin master – @see http://git-scm.com/docs/git-push  "Updates remote refs using local refs, while sending objects necessary to complete the given refs."  In other words, send your local changes back to the remote repo you cloned from.
  • 15. Pulling someone else's changes (remote -> local) – Change Directory into the repository & issue a git pull $ cd path/to/repo $ git pull origin master – @see http://git-scm.com/docs/git-pull  "Incorporates changes from a remote repository into the current branch. In its default mode, git pull is shorthand for git fetch followed by git merge FETCH_HEAD."  In other words, retrieve changes made to the remote repo and merge them into your local repo, updating your working copy to match.
  • 18. Working smart(er) – Merge changes made in a feature branch into another branch, typically development, to then be tested, and ultimately merged to the master branch and tagged. $ cd path/to/repo $ git branch $ git checkout master $ git merge featurename – @see http://git-scm.com/docs/git-merge "Incorporates changes from the named commits (since the time their histories diverged from the current branch) into the current branch. This command is used by git pull to incorporate changes from another repository and can be used by hand to merge changes from one branch into another." In other words, apply changes from another branch to the current one.
  • 19. Wrap Up: Review The most common commands you will use during a normal day/week working with Git to manage versions of code: Download/Create a local repo $ git clone $ git init Checking what's changed $ git status $ git log Storing edits $ git add $ git commit Updating your local repo $ git pull (git fetch) $ git branch $ git merge Storing changes offsite/offbox $ git commit $ git push Storing changes offsite/offbox $ git tag $ git push
  • 20. GOAL To learn to resolve merging conflicts
  • 21. Merge the master branch with style Let us go back to the style branch and merge it with a new master branch. RUN: git checkout style git merge master RESULT: $ git checkout style Switched to branch 'style' $ git merge master Auto-merging lib/hello.html CONFLICT (content): Merge conflict in lib/hello.html Automatic merge failed; fix conflicts and then commit the result. If you open the lib/hello.html you will see:
  • 22. FILE: LIB/HELLO.HTML <!-- Author: Alexander Shvets ([email protected]) --> <html> <head> <<<<<<< HEAD <link type="text/css" rel="stylesheet" media="all" href="style.css" /> ======= <!-- no style --> >>>>>>> master </head> <body> <h1>Hello,World! Life is great!</h1> </body> </html> The first section is the version of the current branch (style) head. The second section is the version of master branch.
  • 23. Resolution of the conflict • You need to resolve the conflict manually. Make changes to lib/hello.html to achieve the following result. FILE: LIB/HELLO.HTML <!-- Author: Alexander Shvets ([email protected]) --> <html> <head> <link type="text/css" rel="stylesheet" media="all" href="style.css" /> </head> <body> <h1>Hello, World! Life is great!</h1> </body> </html>
  • 24. Make a commit of conflict resolution • RUN: git add lib/hello.html git commit -m "Merged master fixed conflict." • RESULT: $ git add lib/hello.html $ git commit -m "Merged master fixed conflict." Recorded resolution for 'lib/hello.html'. [style 645c4e6] Merged master fixed conflict.
  • 26. 26 CONTACT US add.websolution [email protected] us to work “lets talk solution”