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

PPTX
Git like a pro EDD18 - Full edition
PDF
Gitlab installation
PDF
Introduction to git
KEY
gunicorn introduction
PPTX
Intro to Git DevOps Tally Presentation 101615
DOCX
Git github
PDF
Hello git
PDF
Git introduction
Git like a pro EDD18 - Full edition
Gitlab installation
Introduction to git
gunicorn introduction
Intro to Git DevOps Tally Presentation 101615
Git github
Hello git
Git introduction

What's hot (20)

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

Similar to Git guide (20)

PDF
Git best practices workshop
PDF
Download full ebook of Version Control With Git Jon Loeliger instant download...
PPTX
Techoalien git
PPTX
Techoalien git
PPTX
Techoalien git
PPTX
Basics of git
DOCX
Git commands
PDF
A Tutorial for GitHub.pdf
PDF
A Tutorial for GitHub.pdf
PPTX
GIT in a nutshell
PPTX
Git learning
PDF
Git Tutorial A Comprehensive Guide for Beginners.pdf
PDF
Pragmatic version control using Git 1st Edition Travis Swicegood
PPT
git.ppt
PDF
Git basics
PPT
PPT
PPT
PPT
Introduction to Git
Git best practices workshop
Download full ebook of Version Control With Git Jon Loeliger instant download...
Techoalien git
Techoalien git
Techoalien git
Basics of git
Git commands
A Tutorial for GitHub.pdf
A Tutorial for GitHub.pdf
GIT in a nutshell
Git learning
Git Tutorial A Comprehensive Guide for Beginners.pdf
Pragmatic version control using Git 1st Edition Travis Swicegood
git.ppt
Git basics
Introduction to Git
Ad

Recently uploaded (20)

PDF
UEFA_Carbon_Footprint_Calculator_Methology_2.0.pdf
PPTX
ai_satellite_crop_management_20250815030350.pptx
PDF
Abrasive, erosive and cavitation wear.pdf
PPTX
Amdahl’s law is explained in the above power point presentations
PDF
August 2025 - Top 10 Read Articles in Network Security & Its Applications
PPTX
wireless networks, mobile computing.pptx
PPTX
Chemical Technological Processes, Feasibility Study and Chemical Process Indu...
PPTX
Building constraction Conveyance of water.pptx
PDF
20250617 - IR - Global Guide for HR - 51 pages.pdf
PDF
Computer organization and architecuture Digital Notes....pdf
PDF
distributed database system" (DDBS) is often used to refer to both the distri...
PDF
MLpara ingenieira CIVIL, meca Y AMBIENTAL
PPTX
Graph Data Structures with Types, Traversals, Connectivity, and Real-Life App...
PPTX
Information Storage and Retrieval Techniques Unit III
PDF
Unit1 - AIML Chapter 1 concept and ethics
PPTX
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
PDF
Accra-Kumasi Expressway - Prefeasibility Report Volume 1 of 7.11.2018.pdf
PPTX
Principal presentation for NAAC (1).pptx
PPTX
Measurement Uncertainty and Measurement System analysis
PDF
Design Guidelines and solutions for Plastics parts
UEFA_Carbon_Footprint_Calculator_Methology_2.0.pdf
ai_satellite_crop_management_20250815030350.pptx
Abrasive, erosive and cavitation wear.pdf
Amdahl’s law is explained in the above power point presentations
August 2025 - Top 10 Read Articles in Network Security & Its Applications
wireless networks, mobile computing.pptx
Chemical Technological Processes, Feasibility Study and Chemical Process Indu...
Building constraction Conveyance of water.pptx
20250617 - IR - Global Guide for HR - 51 pages.pdf
Computer organization and architecuture Digital Notes....pdf
distributed database system" (DDBS) is often used to refer to both the distri...
MLpara ingenieira CIVIL, meca Y AMBIENTAL
Graph Data Structures with Types, Traversals, Connectivity, and Real-Life App...
Information Storage and Retrieval Techniques Unit III
Unit1 - AIML Chapter 1 concept and ethics
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
Accra-Kumasi Expressway - Prefeasibility Report Volume 1 of 7.11.2018.pdf
Principal presentation for NAAC (1).pptx
Measurement Uncertainty and Measurement System analysis
Design Guidelines and solutions for Plastics parts

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