SlideShare a Scribd company logo
1 of 13
Download to read offline
Git Documentation
Aishwarya R
Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  1
2. Initial git Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  2
2.1. Creating New repository. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  2
2.2. Using git in existing folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  2
2.3. Using git in existing git repository . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  3
3. Making Commits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  4
4. Editing Commits. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  5
5. Working with Branches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  7
6. Merging. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  8
7. Applying Patches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  9
8. Thank you! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  11
1. Introduction
• Through this article I would like to provide some Git commands for people in a
hurry and for all those who are too busy but seek a conduit to git.
Copyright @ Aishwarya R 1
2. Initial git Setup
2.1. Creating New repository
$ git clone https://gitlab.com/aishwarya/git-practice.git
$ cd git-practice
$ touch test.txt
$ git add test.txt
$ git commit -m "add README"
$ git push -u origin master
2.2. Using git in existing folder
$ cd existing_folder
$ git init
$ git remote add new-origin https://gitlab.com/aishwarya/git-
practice.git
$ git add .
$ git commit -m "Initial commit"
$ git push -u new-origin master
Copyright @ Aishwarya R 2
2.3. Using git in existing git repository
$ cd existing_repo
$ git remote add new-origin https://gitlab.com/aishwarya/git-
practice.git
$ git push -u new-origin --all
$ git push -u new-origin --tags
Copyright @ Aishwarya R 3
3. Making Commits
• To know the working tree status and untracked files
$ git status
• Adding untracked files to working tree
$ git add filename
• Adding all the untracked files
$ git add .
• Commit the changes
$ git commit -a -m "Initial commit"
-a - to add modified files
Copyright @ Aishwarya R 4
4. Editing Commits
• Changing the last commit message
$ git commit --amend
• Removing the last commit
$ git reset HEAD~
• Removing number of commits from HEAD
$ git reset HEAD~(N-1)
N - Number of commits, N-1 because index is starts with 0
Example, git reset HEAD~5
for discarding last 6 commits
Copyright @ Aishwarya R 5
• Undoing the commit
$ git revert commit_id
• To view the list of commits
$ git log
• To view the content of particular commit
$ git show commit_id
• To view the history of particular file
$ git log -- filename
Copyright @ Aishwarya R 6
5. Working with Branches
• Creating new branch
$ git checkout -b branch_name
• To view list of all branches
$ git branch -a
• Renaming the branch name
$ git branch -m old_name new_name
• Cloning the specific branch
$ git clone --branch branch_name https://gitlab.com/aishwarya/git-
practice.git
• Removing branch
$ git branch -d branch_name
Copyright @ Aishwarya R 7
6. Merging
• Move to the branch where you want to add changes
$ git checkout branch (where you want to add changes)
• Merging the merging_branch to the current branch
$ git merge merging_branch
• To get an overview of merge state where unmerged paths are files with merge
conflicts.
$ git status
• To view the conflicts in detail
$ git diff
Copyright @ Aishwarya R 8
7. Applying Patches
There may be a situation occurs where you want to apply some of your commits to
another working tree. In that case, you can take every commit as patches from your
working tree and apply it on another working tree.
• Taking patch for particular commits
$ git format-patch -1 commit_id
• Taking patch for N number of commits from HEAD or commit id
$ git format-patch -N HEAD/commit_id -o ~/patches/
-o option to specify the output directory
• Checking the patch before apply
$ git apply --check --ignore-space-change --ignore-whitespace
~/patches/0001-patch1.patch
Copyright @ Aishwarya R 9
• Apply patch
$ git apply --ignore-space-change --ignore-whitespace
~/patches/0001-patch1.patch
• If patch does not apply cleanly, apply part of the patch
$ git apply --reject --ignore-space-change --ignore-whitespace
~/patches/0001-patch1.patch
• Apply patch with commit information like author and commit message.
$ git am --reject --ignore-space-change --ignore-whitespace
~/patches/0001-patch1.patch
• git am uses git apply behind the scenes, but does more work before (reading
commit logs) and after (creating commits).
• Removing patch from the working tree
$ git apply -R ~/patches/0001-patch1.patch
Copyright @ Aishwarya R 10
8. Thank you!
Copyright @ Aishwarya R 11

More Related Content

What's hot

Git: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commandsGit: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commandsth507
 
Pengenalan Git
Pengenalan GitPengenalan Git
Pengenalan Gitfajran
 
Understanding about git
Understanding about gitUnderstanding about git
Understanding about gitSothearin Ren
 
Version Control with Git for Beginners
Version Control with Git for BeginnersVersion Control with Git for Beginners
Version Control with Git for Beginnersbryanbibat
 
Introduction to mercurial
Introduction to mercurialIntroduction to mercurial
Introduction to mercurialIT Booze
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use ItDaniel Kummer
 
CraftCamp for Students - Introduction to git
CraftCamp for Students - Introduction to gitCraftCamp for Students - Introduction to git
CraftCamp for Students - Introduction to gitcraftworkz
 
Git Basics (Professionals)
 Git Basics (Professionals) Git Basics (Professionals)
Git Basics (Professionals)bryanbibat
 
Kotlinのcoroutine、async/awaitと同じでしょ?って思ってたけど意外と洗練されててすごいなぁって思った話をさせてほしい
Kotlinのcoroutine、async/awaitと同じでしょ?って思ってたけど意外と洗練されててすごいなぁって思った話をさせてほしいKotlinのcoroutine、async/awaitと同じでしょ?って思ってたけど意外と洗練されててすごいなぁって思った話をさせてほしい
Kotlinのcoroutine、async/awaitと同じでしょ?って思ってたけど意外と洗練されててすごいなぁって思った話をさせてほしいTakuya Kikuchi
 
Spark手把手:[e2-spk-s01]
Spark手把手:[e2-spk-s01]Spark手把手:[e2-spk-s01]
Spark手把手:[e2-spk-s01]Erhwen Kuo
 
Spark手把手:[e2-spk-s03]
Spark手把手:[e2-spk-s03]Spark手把手:[e2-spk-s03]
Spark手把手:[e2-spk-s03]Erhwen Kuo
 
Getting Started with Capistrano in Ten Easy Steps
Getting Started with Capistrano in Ten Easy StepsGetting Started with Capistrano in Ten Easy Steps
Getting Started with Capistrano in Ten Easy Stepselliando dias
 
Spark手把手:[e2-spk-s02]
Spark手把手:[e2-spk-s02]Spark手把手:[e2-spk-s02]
Spark手把手:[e2-spk-s02]Erhwen Kuo
 
Git Workshop
Git WorkshopGit Workshop
Git Workshopalexyork
 

What's hot (20)

Nginx3
Nginx3Nginx3
Nginx3
 
Git: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commandsGit: An introduction of plumbing and porcelain commands
Git: An introduction of plumbing and porcelain commands
 
Pengenalan Git
Pengenalan GitPengenalan Git
Pengenalan Git
 
Understanding about git
Understanding about gitUnderstanding about git
Understanding about git
 
Version Control with Git for Beginners
Version Control with Git for BeginnersVersion Control with Git for Beginners
Version Control with Git for Beginners
 
Introduction to mercurial
Introduction to mercurialIntroduction to mercurial
Introduction to mercurial
 
Introduction to Sumatra
Introduction to SumatraIntroduction to Sumatra
Introduction to Sumatra
 
Knolx master-slides
Knolx master-slidesKnolx master-slides
Knolx master-slides
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use It
 
CraftCamp for Students - Introduction to git
CraftCamp for Students - Introduction to gitCraftCamp for Students - Introduction to git
CraftCamp for Students - Introduction to git
 
Git Basics (Professionals)
 Git Basics (Professionals) Git Basics (Professionals)
Git Basics (Professionals)
 
Kotlinのcoroutine、async/awaitと同じでしょ?って思ってたけど意外と洗練されててすごいなぁって思った話をさせてほしい
Kotlinのcoroutine、async/awaitと同じでしょ?って思ってたけど意外と洗練されててすごいなぁって思った話をさせてほしいKotlinのcoroutine、async/awaitと同じでしょ?って思ってたけど意外と洗練されててすごいなぁって思った話をさせてほしい
Kotlinのcoroutine、async/awaitと同じでしょ?って思ってたけど意外と洗練されててすごいなぁって思った話をさせてほしい
 
Spark手把手:[e2-spk-s01]
Spark手把手:[e2-spk-s01]Spark手把手:[e2-spk-s01]
Spark手把手:[e2-spk-s01]
 
Git training
Git trainingGit training
Git training
 
Spark手把手:[e2-spk-s03]
Spark手把手:[e2-spk-s03]Spark手把手:[e2-spk-s03]
Spark手把手:[e2-spk-s03]
 
Getting Started with Capistrano in Ten Easy Steps
Getting Started with Capistrano in Ten Easy StepsGetting Started with Capistrano in Ten Easy Steps
Getting Started with Capistrano in Ten Easy Steps
 
Learn Git Basics
Learn Git BasicsLearn Git Basics
Learn Git Basics
 
Spark手把手:[e2-spk-s02]
Spark手把手:[e2-spk-s02]Spark手把手:[e2-spk-s02]
Spark手把手:[e2-spk-s02]
 
Git Workshop
Git WorkshopGit Workshop
Git Workshop
 
Github integration-kostyasha
Github integration-kostyashaGithub integration-kostyasha
Github integration-kostyasha
 

Similar to Git guide

Intermediate Git
Intermediate GitIntermediate Git
Intermediate GitChase Zhang
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubDSC GVP
 
Git the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlGit the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlBecky Todd
 
How to Really Get Git
How to Really Get GitHow to Really Get Git
How to Really Get GitSusan Tan
 
Apache Web server Complete Guide
Apache Web server Complete GuideApache Web server Complete Guide
Apache Web server Complete Guidewebhostingguy
 
Apache Web server Complete Guide
Apache Web server Complete GuideApache Web server Complete Guide
Apache Web server Complete Guidewebhostingguy
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github Max Claus Nunes
 
Git tutorial
Git tutorialGit tutorial
Git tutorialmobaires
 
Princeton jug git_github
Princeton jug git_githubPrinceton jug git_github
Princeton jug git_githubYakov Fain
 
Git Anti-Patterns: How To Mess Up With Git and Love it Again
Git Anti-Patterns: How To Mess Up With Git and Love it AgainGit Anti-Patterns: How To Mess Up With Git and Love it Again
Git Anti-Patterns: How To Mess Up With Git and Love it AgainLemi Orhan Ergin
 

Similar to Git guide (20)

Intermediate Git
Intermediate GitIntermediate Git
Intermediate Git
 
簡單介紹git
簡單介紹git簡單介紹git
簡單介紹git
 
390a gitintro 12au
390a gitintro 12au390a gitintro 12au
390a gitintro 12au
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
 
Git
GitGit
Git
 
sample.pptx
sample.pptxsample.pptx
sample.pptx
 
Git the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlGit the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version control
 
Git 101
Git 101Git 101
Git 101
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Git for-fun-and-productivity
Git for-fun-and-productivityGit for-fun-and-productivity
Git for-fun-and-productivity
 
How to Really Get Git
How to Really Get GitHow to Really Get Git
How to Really Get Git
 
Apache Web server Complete Guide
Apache Web server Complete GuideApache Web server Complete Guide
Apache Web server Complete Guide
 
Apache Web server Complete Guide
Apache Web server Complete GuideApache Web server Complete Guide
Apache Web server Complete Guide
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
 
Introduction git
Introduction gitIntroduction git
Introduction git
 
1-Intro to VC & GIT PDF.pptx
1-Intro to VC & GIT PDF.pptx1-Intro to VC & GIT PDF.pptx
1-Intro to VC & GIT PDF.pptx
 
Git cheatsheet
Git cheatsheetGit cheatsheet
Git cheatsheet
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Princeton jug git_github
Princeton jug git_githubPrinceton jug git_github
Princeton jug git_github
 
Git Anti-Patterns: How To Mess Up With Git and Love it Again
Git Anti-Patterns: How To Mess Up With Git and Love it AgainGit Anti-Patterns: How To Mess Up With Git and Love it Again
Git Anti-Patterns: How To Mess Up With Git and Love it Again
 

Recently uploaded

Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...Call girls in Ahmedabad High profile
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...ranjana rawat
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 

Recently uploaded (20)

★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 

Git guide

  • 2. Table of Contents 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  1 2. Initial git Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  2 2.1. Creating New repository. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  2 2.2. Using git in existing folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  2 2.3. Using git in existing git repository . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  3 3. Making Commits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  4 4. Editing Commits. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  5 5. Working with Branches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  7 6. Merging. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  8 7. Applying Patches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  9 8. Thank you! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  11
  • 3. 1. Introduction • Through this article I would like to provide some Git commands for people in a hurry and for all those who are too busy but seek a conduit to git. Copyright @ Aishwarya R 1
  • 4. 2. Initial git Setup 2.1. Creating New repository $ git clone https://gitlab.com/aishwarya/git-practice.git $ cd git-practice $ touch test.txt $ git add test.txt $ git commit -m "add README" $ git push -u origin master 2.2. Using git in existing folder $ cd existing_folder $ git init $ git remote add new-origin https://gitlab.com/aishwarya/git- practice.git $ git add . $ git commit -m "Initial commit" $ git push -u new-origin master Copyright @ Aishwarya R 2
  • 5. 2.3. Using git in existing git repository $ cd existing_repo $ git remote add new-origin https://gitlab.com/aishwarya/git- practice.git $ git push -u new-origin --all $ git push -u new-origin --tags Copyright @ Aishwarya R 3
  • 6. 3. Making Commits • To know the working tree status and untracked files $ git status • Adding untracked files to working tree $ git add filename • Adding all the untracked files $ git add . • Commit the changes $ git commit -a -m "Initial commit" -a - to add modified files Copyright @ Aishwarya R 4
  • 7. 4. Editing Commits • Changing the last commit message $ git commit --amend • Removing the last commit $ git reset HEAD~ • Removing number of commits from HEAD $ git reset HEAD~(N-1) N - Number of commits, N-1 because index is starts with 0 Example, git reset HEAD~5 for discarding last 6 commits Copyright @ Aishwarya R 5
  • 8. • Undoing the commit $ git revert commit_id • To view the list of commits $ git log • To view the content of particular commit $ git show commit_id • To view the history of particular file $ git log -- filename Copyright @ Aishwarya R 6
  • 9. 5. Working with Branches • Creating new branch $ git checkout -b branch_name • To view list of all branches $ git branch -a • Renaming the branch name $ git branch -m old_name new_name • Cloning the specific branch $ git clone --branch branch_name https://gitlab.com/aishwarya/git- practice.git • Removing branch $ git branch -d branch_name Copyright @ Aishwarya R 7
  • 10. 6. Merging • Move to the branch where you want to add changes $ git checkout branch (where you want to add changes) • Merging the merging_branch to the current branch $ git merge merging_branch • To get an overview of merge state where unmerged paths are files with merge conflicts. $ git status • To view the conflicts in detail $ git diff Copyright @ Aishwarya R 8
  • 11. 7. Applying Patches There may be a situation occurs where you want to apply some of your commits to another working tree. In that case, you can take every commit as patches from your working tree and apply it on another working tree. • Taking patch for particular commits $ git format-patch -1 commit_id • Taking patch for N number of commits from HEAD or commit id $ git format-patch -N HEAD/commit_id -o ~/patches/ -o option to specify the output directory • Checking the patch before apply $ git apply --check --ignore-space-change --ignore-whitespace ~/patches/0001-patch1.patch Copyright @ Aishwarya R 9
  • 12. • Apply patch $ git apply --ignore-space-change --ignore-whitespace ~/patches/0001-patch1.patch • If patch does not apply cleanly, apply part of the patch $ git apply --reject --ignore-space-change --ignore-whitespace ~/patches/0001-patch1.patch • Apply patch with commit information like author and commit message. $ git am --reject --ignore-space-change --ignore-whitespace ~/patches/0001-patch1.patch • git am uses git apply behind the scenes, but does more work before (reading commit logs) and after (creating commits). • Removing patch from the working tree $ git apply -R ~/patches/0001-patch1.patch Copyright @ Aishwarya R 10
  • 13. 8. Thank you! Copyright @ Aishwarya R 11