SlideShare a Scribd company logo
Git - GitHub
Presented By:
Nitin Goel
About Git
• Created by Linus Torvalds, creator of Linux, in 2005
– Came out of Linux development community
– Designed to do version control on Linux kernel
• Goals of Git:
– Speed
– Support for non-linear development (thousands of parallel branches)
– Fully distributed
– Able to handle large projects efficiently
Centralized VCS
• In Subversion, CVS, Perforce, etc.
A central server repository (repo)
holds the "official copy" of the
code
• The server maintains the sole
version history of the repo
• You make "checkouts" of it to
your local copy
• You make local modifications
• Your changes are not versioned
• When you're done, you "check in"
back to the server
• Your check in increments the
repo's version
Distributed VCS (Git)
• In git, mercurial, etc., you don't
"checkout" from a central repo, you
"clone" it and "pull" changes from it
• Your local repo is a complete copy of
everything on the remote server
• Yours is "just as good" as theirs
• Many operations are local:
– check in/out from local repo
– commit changes to local repo
– local repo keeps version history
• When you're ready, you can "push"
changes back to server
Version Control
• Version control is a system that records changes to a file or set of files over
time so that you can recall specific versions later.
• Allows for collaborative development
• Allows you to know who made what changes and when
• Allows you to revert any changes and go back to a previous state
• Three of the most popular version control systems are:
 Git
 Subversion
 Mercurial
Git vs Github
• Git is a revision control system, a tool to manage your source code history.
• Github is a hosting service for Git repositories.
Terminology
Version Control System / Source Code Manager
 A version control system (abbreviated as VCS) is a tool that manages different versions of
source code. A source code manager (abbreviated as SCM) is another name for a version
control system.
Commit
 Git thinks of its data like a set of snapshots of a mini file system. Every time you commit (save
the state of your project in Git), it basically takes a picture of what all your files look like at
that moment and stores a reference to that snapshot. You can think of it as a save point in a
game - it saves your project's files and any information about them.
Repository / repo
 A repository is a directory which contains your project work, as well as a few files (hidden by
default on Mac OS X) which are used to communicate with Git. Repositories can exist either
locally on your computer or as a remote copy on another computer. A repository is made up
of commits.
Terminology
Working Directory
 The Working Directory is the files that you see in your computer's file system. When you open your project files up
on a code editor, you're working with files in the Working Directory.
 This is in contrast to the files that have been saved (in commits!) in the repository.
Checkout
 A checkout is when content in the repository has been copied to the Working Directory.
Staging Area / Staging Index / Index
 A file in the Git directory that stores information about what will go into your next commit. You can think of the staging area as a prep
table where Git will take the next commit. Files on the Staging Index are poised to be added to the repository.
SHA(Secure Hash Algorithm)
 A SHA is basically an ID number for each commit. Here's what a commit's SHA might look
like: e2adf8ae3e2e4ed40add75cc44cf9d0a869afeb6.
Branch
 A branch is when a new line of development is created that diverges from the main line of development. This
alternative line of development can continue without altering the main line.
Install Git on Windows
• Download the latest Git for windows installer.
• When you've successfully started the installer, you should see the Git
Setup wizard screen. Follow the Next and Finish prompts to complete the
installation.
• Open a Command Prompt (or Git Bash if during installation you elected
not to use Git from the Windows Command Prompt).
• Run the following commands to configure your Git. These details will be
associated with any commits that you create.
Git Configuration
• # sets up Git with your name
git config --global user.name "<Your-Full-Name>"
• # sets up Git with your email
git config --global user.email "<your-email-address>"
• # makes sure that Git output is colored
git config --global color.ui auto
• # displays the original state in a conflict
git config --global merge.conflictstyle diff3
• git config --list
Associating text editors with Git
• Using Atom as your editor
– Install Atom.
– Open Git Bash.
– Type this command:
git config --global core.editor
“C:/Users/USERNAME/AppData/Local/atom/bin/atom.cmd”
Using Sublime Text as your editor
– Install Sublime Text 3.
– Open Git Bash.
– Type this command:
git config --global core.editor "'c:/program files/sublime text 3/subl.exe'
-w"
• Using Notepad++ as your editor
– Install Notepad++.
– Open Git Bash.
– Type this command:
git config --global core.editor "'C:/Program Files
(x86)/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -
noPlugin"
git init
• Running the git init command sets up all of the necessary files and
directories that Git will use to keep track of everything.
• All of these files are stored in a directory called .git (notice the . at the
beginning - that means it'll be a hidden directory on Mac/Linux).
• This .git directory is the "repo"! This is where git records all of the commits
and keeps track of everything!
Local git areas
git clone
• The git clone command is used to create an identical copy of an existing
repository.
$ git clone <path-to-repository-to-clone>
This command:
 takes the path to an existing repository
 by default will create a directory with the same name as the repository that's being
cloned
 can be given a second argument that will be used as the name of the directory
 will create the new repository inside of the current working directory
git status
• The git status command displays the state of the working directory and the staging
area.
• It lets you see which changes have been staged, which haven’t, and which files
aren’t being tracked by Git.
• Status output does not show you any information regarding the committed project
history.
git log
• The git log command is used to display all of the commits of a repository.
• By default, this command displays:
 the SHA
 the author
 the date
 and the message
git add
The git add command is used to move files from the Working Directory to the Staging Index.
$ git add <file1> <file2> … <fileN>
This command:
• takes a space-separated list of file names
• alternatively, the period . can be used in place of a list of files to tell Git to add the current
directory (and all nested files)
• git rm --cached <file> command can be used to remove a file from staging Index. This
command will not destroy any of your work, it just removes it from the Staging Index.
git commit
The git commit command takes files from the Staging Index and saves them in
the repository.
$ git commit
This command:
• will open the code editor that is specified in your configuration
• (check out the Git configuration step from the first lesson to configure
your editor)
• Inside the code editor:
– a commit message must be supplied
– lines that start with a # are comments and will not be recorded
– save the file after adding a commit message
– close the editor to make the commit
Then, use git log to review the commit you just made!
Commit message
Do
• do keep the message short (less than 60-ish characters)
• do explain what the commit does (not how or why!)
Do not
• do not explain why the changes are made (more on this below)
• do not explain how the changes are made (that's what git log -p is for!)
• do not use the word "and"
• if you have to use "and", your commit message is probably doing too many
changes - break the changes into separate commits
• e.g. "make the background color pink and increase the size of the sidebar"
git log --oneline
• This command shortens the SHA and commit message to just one line
• Q key is pressed to co come out to regular command prompt
git log --stat
 displays the file(s) that have been modified
 displays the number of lines that have been added/removed
 displays a summary line with the total number of modified files and lines
that have been added/removed
git log –p or git log --patch
This command adds the following to the default output:
 displays the files that have been modified
 displays the location of the lines that have been added/removed
 displays the actual changes that have been made
git show
The git show command will show only one commit.
By default, git show displays:
the commit
the author
the date
the commit message
the patch information
git diff
git diff command is used to see changes that have been made but haven't
been committed, yet:
$ git diff
This command displays:
• the files that have been modified
• the location of the lines that have been added/removed
• the actual changes that have been made
git ignore
• Git sees every file in your working copy as one of three things:
– tracked - a file which has been previously staged or committed;
– untracked - a file which has not been staged or committed; or
– ignored - a file which Git has been explicitly told to ignore.
– Ignored files are usually build artifacts and machine generated files
that can be derived from your repository source or should otherwise
not be committed. Some common examples are:
 compiled code, such as .o, .pyc, and .class files
 build output directories, such as /bin, /out, or /target
 files generated at runtime, such as .log, .lock, or .tmp
 hidden system files, such as .DS_Store or Thumbs.db
git tag
• Git has the ability to tag specific points in history as being important.
• Git supports two types of tags: lightweight and annotated.
 A lightweight tag is very much like a branch that doesn’t change — it’s
just a pointer to a specific commit.
git tag v1.0
 Annotated tags are stored as full objects in the Git database. They’re
checksummed; contain the tagger name, email, and date; have a
tagging message; and can be signed and verified with GNU Privacy
Guard (GPG).
git tag -a v1.0 -m “Insert message.“
 To delete tag
git –d v1.0 or git --delete v1.0
git branch
• Branch enables programmer to work in the same project in different
isolated environments.
• When it is required to add a new feature or fix a bug—no matter how big
or how small ,a new branch can be created to encapsulate the changes.
Commands
• git branch list all of the branches in your repository.
• git branch <branch> create a new branch called <branch>. This
does not check out the new branch.
• git branch -d <branch> delete the specified branch. This is a “safe”
operation in that Git prevents you from deleting the branch if it has
unmerged changes.
• git branch -D <branch> force delete the specified branch, even if it has
unmerged changes.
• git branch -m <branch> rename the current branch to <branch>.
• git checkout <branch> checkout to branch called <branch>.
• git checkout –b <branch> create a new branch called <branch> and
checkout simultaneously.
git merge
The git merge command lets you take the independent lines of development
created by git branch and integrate them into a single branch.
git merge <branch>
There are two types of merging:
1. Fast forward merge
2. 3-way merge.
Fast forward merge
• A fast-forward merge can occur when there is a linear path from the
current branch tip to the target branch.
• Before merge:
• After merge:
3-way merge
• A fast-forward merge is not possible if the branches have diverged. When
there is not a linear path to the target branch, Git has no choice but to
combine them via a 3-way merge. 3-way merges use a dedicated commit
to tie together the two histories.
• Before Merge
• After Merge
Merge conflict
• If the two branches you're trying to merge both changed the same part of
the same file, Git won't be able to figure out which version to use. When
such a situation occurs, it stops right before the merge commit so that you
can resolve the conflicts manually.
• visual markers to represent conflict are: <<<<<<<, =======, and >>>>>>>.
--amend
• Git commit –amend command is used to edit most recent commit.
git commit --amend
• Steps involved are:
– edit the file(s)
– save the file(s)
– stage the file(s)
– and run git commit --amend
git revert
The git revert command is used to reverse a previously made commit:
$ git revert <SHA-of-commit-to-revert>
This command:
 will undo the changes that were made by the provided commit
 creates a new commit to record the change
git reset
• git reset --option <SHA> command is used to erase commits. There are
three options to reset.
1. –soft (erased commits shifts to staging index)
2. –mixed(default and (erased commits shifts to working directory)
3. –hard(erases directly)
Remote repositry
• A remote repository is the same Git repository like yours but it exists
somewhere else.
• Remotes can be accessed in a couple of ways:
– with a URL
– path to a file system
• we can interact and control a remote repository is through the Git remote
command:
– $ git remote
git push
• Create a new repository on GitHub. To avoid errors, do not initialize the
new repository with README, license, or .gitignore files. You can add
these files after your project has been pushed to GitHub.
• Open Git Bash.
• Change the current working directory to your local project.
• Initialize the local directory as a Git repository.
– git init
• Add the files in your new local repository. This stages them for the first
commit.
– git add .
• Commit the files that you've staged in your local repository.
– git commit -m "First commit"
• Copy remote repository URL field at the top of your GitHub repository's
Quick Setup page, click to copy the remote repository URL.
• In the Command prompt, add the URL for the remote repository where
your local repository will be pushed.
-git remote add origin remote repository URL
• git remote –v command verifies the new remote URL
• Push the changes in your local repository to GitHub.
-git push origin master
# Pushes the changes in your local repository up to the remote repository you
specified as the origin
git fetch or git pull
• The git fetch command downloads commits, files, and refs from a remote
repository into your local repo. Git isolates fetched content as a from
existing local content, it has absolutely no effect on your local
development work.
– git push origin master
– git fetch origin master
• This makes fetching a safe way to review commits before integrating them
with your local repository.
• git fetch is the 'safe' version of the two commands. It will download the
remote content but not update your local repo's working state, leaving
your current work intact. git pull is the more aggressive alternative, it will
download the remote content for the active local branch and immediately
execute git merge to create a merge commit for the new remote content.
Thank You

More Related Content

What's hot

What's hot (20)

Git
GitGit
Git
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
github-actions.pdf
github-actions.pdfgithub-actions.pdf
github-actions.pdf
 
Introduction to github slideshare
Introduction to github slideshareIntroduction to github slideshare
Introduction to github slideshare
 
Introducing GitLab (September 2018)
Introducing GitLab (September 2018)Introducing GitLab (September 2018)
Introducing GitLab (September 2018)
 
DevOps with GitHub Actions
DevOps with GitHub ActionsDevOps with GitHub Actions
DevOps with GitHub Actions
 
Git training v10
Git training v10Git training v10
Git training v10
 
Introduction to GitHub Actions
Introduction to GitHub ActionsIntroduction to GitHub Actions
Introduction to GitHub Actions
 
Git and git flow
Git and git flowGit and git flow
Git and git flow
 
CICD Pipeline Using Github Actions
CICD Pipeline Using Github ActionsCICD Pipeline Using Github Actions
CICD Pipeline Using Github Actions
 
CD using ArgoCD(KnolX).pdf
CD using ArgoCD(KnolX).pdfCD using ArgoCD(KnolX).pdf
CD using ArgoCD(KnolX).pdf
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
 
GitOps with ArgoCD
GitOps with ArgoCDGitOps with ArgoCD
GitOps with ArgoCD
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Github
GithubGithub
Github
 
GitHub Basics - Derek Bable
GitHub Basics - Derek BableGitHub Basics - Derek Bable
GitHub Basics - Derek Bable
 
GitLab.pptx
GitLab.pptxGitLab.pptx
GitLab.pptx
 
Learning git
Learning gitLearning git
Learning git
 
Gitlab, GitOps & ArgoCD
Gitlab, GitOps & ArgoCDGitlab, GitOps & ArgoCD
Gitlab, GitOps & ArgoCD
 

Similar to Git hub

Git walkthrough
Git walkthroughGit walkthrough
Git walkthroughBimal Jain
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configurationKishor Kumar
 
Introduction to git and githhub with practicals.pptx
Introduction to git and githhub with practicals.pptxIntroduction to git and githhub with practicals.pptx
Introduction to git and githhub with practicals.pptxAbdul Salam
 
Introduction to git hub
Introduction to git hubIntroduction to git hub
Introduction to git hubNaveen Pandey
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github Max Claus Nunes
 
Source Code Management with Git
Source Code Management with GitSource Code Management with Git
Source Code Management with GitThings Lab
 
CSE 390 Lecture 9 - Version Control with GIT
CSE 390 Lecture 9 - Version Control with GITCSE 390 Lecture 9 - Version Control with GIT
CSE 390 Lecture 9 - Version Control with GITPouriaQashqai1
 
IS - section 1 - modifiedFinal information system.pptx
IS - section 1 - modifiedFinal information system.pptxIS - section 1 - modifiedFinal information system.pptx
IS - section 1 - modifiedFinal information system.pptxNaglaaAbdelhady
 
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGeoff Hoffman
 
Git for developers
Git for developersGit for developers
Git for developersHacen Dadda
 
git and github-1.pptx
git and github-1.pptxgit and github-1.pptx
git and github-1.pptxtnscharishma
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Gitatishgoswami
 

Similar to Git hub (20)

git.ppt.pdf
git.ppt.pdfgit.ppt.pdf
git.ppt.pdf
 
Git walkthrough
Git walkthroughGit walkthrough
Git walkthrough
 
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 101
Git 101Git 101
Git 101
 
GIT.pptx
GIT.pptxGIT.pptx
GIT.pptx
 
Learn Git Basics
Learn Git BasicsLearn Git Basics
Learn Git Basics
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configuration
 
Introduction to git and githhub with practicals.pptx
Introduction to git and githhub with practicals.pptxIntroduction to git and githhub with practicals.pptx
Introduction to git and githhub with practicals.pptx
 
Introduction to git hub
Introduction to git hubIntroduction to git hub
Introduction to git hub
 
Git introduction
Git introductionGit introduction
Git introduction
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
 
Source Code Management with Git
Source Code Management with GitSource Code Management with Git
Source Code Management with Git
 
CSE 390 Lecture 9 - Version Control with GIT
CSE 390 Lecture 9 - Version Control with GITCSE 390 Lecture 9 - Version Control with GIT
CSE 390 Lecture 9 - Version Control with GIT
 
IS - section 1 - modifiedFinal information system.pptx
IS - section 1 - modifiedFinal information system.pptxIS - section 1 - modifiedFinal information system.pptx
IS - section 1 - modifiedFinal information system.pptx
 
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using Git
 
Git for developers
Git for developersGit for developers
Git for developers
 
git and github-1.pptx
git and github-1.pptxgit and github-1.pptx
git and github-1.pptx
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Mini-training: Let’s Git It!
Mini-training: Let’s Git It!Mini-training: Let’s Git It!
Mini-training: Let’s Git It!
 
sample.pptx
sample.pptxsample.pptx
sample.pptx
 

Recently uploaded

Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesRased Khan
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsCol Mukteshwar Prasad
 
Advances in production technology of Grapes.pdf
Advances in production technology of Grapes.pdfAdvances in production technology of Grapes.pdf
Advances in production technology of Grapes.pdfDr. M. Kumaresan Hort.
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonSteve Thomason
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxJenilouCasareno
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxbennyroshan06
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfTamralipta Mahavidyalaya
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportAvinash Rai
 
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfQucHHunhnh
 
Benefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational ResourcesBenefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational Resourcesdimpy50
 
2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptxmansk2
 
The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resourcesaileywriter
 
Accounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdfAccounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdfYibeltalNibretu
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleCeline George
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXMIRIAMSALINAS13
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
 

Recently uploaded (20)

Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matrices
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Advances in production technology of Grapes.pdf
Advances in production technology of Grapes.pdfAdvances in production technology of Grapes.pdf
Advances in production technology of Grapes.pdf
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
NCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdfNCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdf
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
 
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
 
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
 
Benefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational ResourcesBenefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational Resources
 
2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx
 
The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resources
 
Accounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdfAccounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdf
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 

Git hub

  • 1.
  • 2. Git - GitHub Presented By: Nitin Goel
  • 3. About Git • Created by Linus Torvalds, creator of Linux, in 2005 – Came out of Linux development community – Designed to do version control on Linux kernel • Goals of Git: – Speed – Support for non-linear development (thousands of parallel branches) – Fully distributed – Able to handle large projects efficiently
  • 4. Centralized VCS • In Subversion, CVS, Perforce, etc. A central server repository (repo) holds the "official copy" of the code • The server maintains the sole version history of the repo • You make "checkouts" of it to your local copy • You make local modifications • Your changes are not versioned • When you're done, you "check in" back to the server • Your check in increments the repo's version
  • 5. Distributed VCS (Git) • In git, mercurial, etc., you don't "checkout" from a central repo, you "clone" it and "pull" changes from it • Your local repo is a complete copy of everything on the remote server • Yours is "just as good" as theirs • Many operations are local: – check in/out from local repo – commit changes to local repo – local repo keeps version history • When you're ready, you can "push" changes back to server
  • 6. Version Control • Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later. • Allows for collaborative development • Allows you to know who made what changes and when • Allows you to revert any changes and go back to a previous state • Three of the most popular version control systems are:  Git  Subversion  Mercurial
  • 7. Git vs Github • Git is a revision control system, a tool to manage your source code history. • Github is a hosting service for Git repositories.
  • 8. Terminology Version Control System / Source Code Manager  A version control system (abbreviated as VCS) is a tool that manages different versions of source code. A source code manager (abbreviated as SCM) is another name for a version control system. Commit  Git thinks of its data like a set of snapshots of a mini file system. Every time you commit (save the state of your project in Git), it basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot. You can think of it as a save point in a game - it saves your project's files and any information about them. Repository / repo  A repository is a directory which contains your project work, as well as a few files (hidden by default on Mac OS X) which are used to communicate with Git. Repositories can exist either locally on your computer or as a remote copy on another computer. A repository is made up of commits.
  • 9. Terminology Working Directory  The Working Directory is the files that you see in your computer's file system. When you open your project files up on a code editor, you're working with files in the Working Directory.  This is in contrast to the files that have been saved (in commits!) in the repository. Checkout  A checkout is when content in the repository has been copied to the Working Directory. Staging Area / Staging Index / Index  A file in the Git directory that stores information about what will go into your next commit. You can think of the staging area as a prep table where Git will take the next commit. Files on the Staging Index are poised to be added to the repository. SHA(Secure Hash Algorithm)  A SHA is basically an ID number for each commit. Here's what a commit's SHA might look like: e2adf8ae3e2e4ed40add75cc44cf9d0a869afeb6. Branch  A branch is when a new line of development is created that diverges from the main line of development. This alternative line of development can continue without altering the main line.
  • 10. Install Git on Windows • Download the latest Git for windows installer. • When you've successfully started the installer, you should see the Git Setup wizard screen. Follow the Next and Finish prompts to complete the installation. • Open a Command Prompt (or Git Bash if during installation you elected not to use Git from the Windows Command Prompt). • Run the following commands to configure your Git. These details will be associated with any commits that you create.
  • 11. Git Configuration • # sets up Git with your name git config --global user.name "<Your-Full-Name>" • # sets up Git with your email git config --global user.email "<your-email-address>" • # makes sure that Git output is colored git config --global color.ui auto • # displays the original state in a conflict git config --global merge.conflictstyle diff3 • git config --list
  • 12. Associating text editors with Git • Using Atom as your editor – Install Atom. – Open Git Bash. – Type this command: git config --global core.editor “C:/Users/USERNAME/AppData/Local/atom/bin/atom.cmd” Using Sublime Text as your editor – Install Sublime Text 3. – Open Git Bash. – Type this command: git config --global core.editor "'c:/program files/sublime text 3/subl.exe' -w"
  • 13. • Using Notepad++ as your editor – Install Notepad++. – Open Git Bash. – Type this command: git config --global core.editor "'C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -notabbar -nosession - noPlugin"
  • 14. git init • Running the git init command sets up all of the necessary files and directories that Git will use to keep track of everything. • All of these files are stored in a directory called .git (notice the . at the beginning - that means it'll be a hidden directory on Mac/Linux). • This .git directory is the "repo"! This is where git records all of the commits and keeps track of everything!
  • 16.
  • 17. git clone • The git clone command is used to create an identical copy of an existing repository. $ git clone <path-to-repository-to-clone> This command:  takes the path to an existing repository  by default will create a directory with the same name as the repository that's being cloned  can be given a second argument that will be used as the name of the directory  will create the new repository inside of the current working directory
  • 18. git status • The git status command displays the state of the working directory and the staging area. • It lets you see which changes have been staged, which haven’t, and which files aren’t being tracked by Git. • Status output does not show you any information regarding the committed project history.
  • 19.
  • 20. git log • The git log command is used to display all of the commits of a repository. • By default, this command displays:  the SHA  the author  the date  and the message
  • 21. git add The git add command is used to move files from the Working Directory to the Staging Index. $ git add <file1> <file2> … <fileN> This command: • takes a space-separated list of file names • alternatively, the period . can be used in place of a list of files to tell Git to add the current directory (and all nested files) • git rm --cached <file> command can be used to remove a file from staging Index. This command will not destroy any of your work, it just removes it from the Staging Index.
  • 22. git commit The git commit command takes files from the Staging Index and saves them in the repository. $ git commit This command: • will open the code editor that is specified in your configuration • (check out the Git configuration step from the first lesson to configure your editor) • Inside the code editor: – a commit message must be supplied – lines that start with a # are comments and will not be recorded – save the file after adding a commit message – close the editor to make the commit Then, use git log to review the commit you just made!
  • 23.
  • 24. Commit message Do • do keep the message short (less than 60-ish characters) • do explain what the commit does (not how or why!) Do not • do not explain why the changes are made (more on this below) • do not explain how the changes are made (that's what git log -p is for!) • do not use the word "and" • if you have to use "and", your commit message is probably doing too many changes - break the changes into separate commits • e.g. "make the background color pink and increase the size of the sidebar"
  • 25. git log --oneline • This command shortens the SHA and commit message to just one line • Q key is pressed to co come out to regular command prompt
  • 26. git log --stat  displays the file(s) that have been modified  displays the number of lines that have been added/removed  displays a summary line with the total number of modified files and lines that have been added/removed
  • 27. git log –p or git log --patch This command adds the following to the default output:  displays the files that have been modified  displays the location of the lines that have been added/removed  displays the actual changes that have been made
  • 28. git show The git show command will show only one commit. By default, git show displays: the commit the author the date the commit message the patch information
  • 29. git diff git diff command is used to see changes that have been made but haven't been committed, yet: $ git diff This command displays: • the files that have been modified • the location of the lines that have been added/removed • the actual changes that have been made
  • 30.
  • 31. git ignore • Git sees every file in your working copy as one of three things: – tracked - a file which has been previously staged or committed; – untracked - a file which has not been staged or committed; or – ignored - a file which Git has been explicitly told to ignore. – Ignored files are usually build artifacts and machine generated files that can be derived from your repository source or should otherwise not be committed. Some common examples are:  compiled code, such as .o, .pyc, and .class files  build output directories, such as /bin, /out, or /target  files generated at runtime, such as .log, .lock, or .tmp  hidden system files, such as .DS_Store or Thumbs.db
  • 32. git tag • Git has the ability to tag specific points in history as being important. • Git supports two types of tags: lightweight and annotated.  A lightweight tag is very much like a branch that doesn’t change — it’s just a pointer to a specific commit. git tag v1.0  Annotated tags are stored as full objects in the Git database. They’re checksummed; contain the tagger name, email, and date; have a tagging message; and can be signed and verified with GNU Privacy Guard (GPG). git tag -a v1.0 -m “Insert message.“  To delete tag git –d v1.0 or git --delete v1.0
  • 33. git branch • Branch enables programmer to work in the same project in different isolated environments. • When it is required to add a new feature or fix a bug—no matter how big or how small ,a new branch can be created to encapsulate the changes.
  • 34. Commands • git branch list all of the branches in your repository. • git branch <branch> create a new branch called <branch>. This does not check out the new branch. • git branch -d <branch> delete the specified branch. This is a “safe” operation in that Git prevents you from deleting the branch if it has unmerged changes. • git branch -D <branch> force delete the specified branch, even if it has unmerged changes. • git branch -m <branch> rename the current branch to <branch>. • git checkout <branch> checkout to branch called <branch>. • git checkout –b <branch> create a new branch called <branch> and checkout simultaneously.
  • 35. git merge The git merge command lets you take the independent lines of development created by git branch and integrate them into a single branch. git merge <branch> There are two types of merging: 1. Fast forward merge 2. 3-way merge.
  • 36. Fast forward merge • A fast-forward merge can occur when there is a linear path from the current branch tip to the target branch.
  • 37. • Before merge: • After merge:
  • 38. 3-way merge • A fast-forward merge is not possible if the branches have diverged. When there is not a linear path to the target branch, Git has no choice but to combine them via a 3-way merge. 3-way merges use a dedicated commit to tie together the two histories.
  • 39.
  • 40. • Before Merge • After Merge
  • 41. Merge conflict • If the two branches you're trying to merge both changed the same part of the same file, Git won't be able to figure out which version to use. When such a situation occurs, it stops right before the merge commit so that you can resolve the conflicts manually. • visual markers to represent conflict are: <<<<<<<, =======, and >>>>>>>.
  • 42. --amend • Git commit –amend command is used to edit most recent commit. git commit --amend • Steps involved are: – edit the file(s) – save the file(s) – stage the file(s) – and run git commit --amend
  • 43. git revert The git revert command is used to reverse a previously made commit: $ git revert <SHA-of-commit-to-revert> This command:  will undo the changes that were made by the provided commit  creates a new commit to record the change
  • 44. git reset • git reset --option <SHA> command is used to erase commits. There are three options to reset. 1. –soft (erased commits shifts to staging index) 2. –mixed(default and (erased commits shifts to working directory) 3. –hard(erases directly)
  • 45. Remote repositry • A remote repository is the same Git repository like yours but it exists somewhere else. • Remotes can be accessed in a couple of ways: – with a URL – path to a file system • we can interact and control a remote repository is through the Git remote command: – $ git remote
  • 46. git push • Create a new repository on GitHub. To avoid errors, do not initialize the new repository with README, license, or .gitignore files. You can add these files after your project has been pushed to GitHub. • Open Git Bash. • Change the current working directory to your local project. • Initialize the local directory as a Git repository. – git init • Add the files in your new local repository. This stages them for the first commit. – git add . • Commit the files that you've staged in your local repository. – git commit -m "First commit"
  • 47. • Copy remote repository URL field at the top of your GitHub repository's Quick Setup page, click to copy the remote repository URL. • In the Command prompt, add the URL for the remote repository where your local repository will be pushed. -git remote add origin remote repository URL • git remote –v command verifies the new remote URL • Push the changes in your local repository to GitHub. -git push origin master # Pushes the changes in your local repository up to the remote repository you specified as the origin
  • 48. git fetch or git pull • The git fetch command downloads commits, files, and refs from a remote repository into your local repo. Git isolates fetched content as a from existing local content, it has absolutely no effect on your local development work. – git push origin master – git fetch origin master • This makes fetching a safe way to review commits before integrating them with your local repository. • git fetch is the 'safe' version of the two commands. It will download the remote content but not update your local repo's working state, leaving your current work intact. git pull is the more aggressive alternative, it will download the remote content for the active local branch and immediately execute git merge to create a merge commit for the new remote content.