KEMBAR78
Git and github fundamentals | PPTX
Git and Github Fundamentals
What is Git?
â—Ź Git is an Open Source Distributed
Version Control System (VCS).
â—Ź Git was developed by Linus Torvalds in 2005.
â—Ź The same person who has developed
Linux Operating System.
What is Version Control System (VCS)
â—Ź 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.
â—Ź For an Example: You have created an App which is on 1.0 version. Suppose you
want to add a feature and so the App is upgraded to 1.1 version.
â—Ź But after few days the app is crashing because of the feature. So now you want to
rollback to 1.0 version.
â—Ź So here VCS comes into picture. You can track all the changes to file made from
particular checkpoint (commit).
What is Github?
â—Ź GitHub is a code hosting platform for version control and
collaboration. It lets you and others work together on projects from
anywhere.
â—Ź Other Alternatives are: Gitlab, Bit-Bucket
Git Commands
â—Ź git --version
â—Ź git init
â—Ź git add
â—Ź git commit
â—Ź git status
â—Ź git diff
â—Ź git log
â—Ź git clone
â—Ź git remote
â—Ź git push
â—Ź git pull
â—Ź git branch
â—Ź git checkout
â—Ź git merge
git --version
â—Ź git --version - Returns the version of the git
installed on the machine.
git init
â—Ź git init - Creates an empty Git repository or
reinitialize the existing one.
git add
â—Ź git add [filename] - Add file contents to staging
area
â—Ź git add . - Add all the changed files to staging
area.
â—‹ Staging Area - Git knows what files are changed,
but doesn’t know why changed.
git commit
● git commit -m “commit message” - Create a
new commit containing the current contents of the
index and the given log message describing the
changes.
git status
â—Ź git status - Show the working tree status.
â—‹ Gives the list of files changed
git diff
â—Ź git diff - Show changes between commits,
commit and working tree, etc
â—‹ git diff [filename] - Shows the content
changed in file after last commit.
git log
â—Ź git log - Shows the commit logs.
git clone
â—Ź git clone - Clone a repository into a new
directory.
git remote
â—Ź git remote - Adds a remote named <name> for
the repository at <url>
â—‹ git remote add origin [url]
git push
â—Ź git push - Update remote refs along with
associated objects.
â—‹ git push origin master - update local branch
with remote branch.
git pull
â—Ź git pull - Fetch from and integrate with another
repository or a local branch.
â—‹ git pull origin master - Fetch from master
branch of remote repository and integrate with
local branch.
git branch
â—Ź git branch - List all the branches
â—‹ git branch [branch-name] - Creates a branch
with name as [branch-name]
git checkout
â—Ź git checkout - Switch branches or restore
working tree files.
â—‹ git checkout [branch-name] - Checkout to
[branch-name]
â—‹ Git checkout -b [branch-name] - Creates an
checkout to [branch-name]
git merge
â—Ź git merge - Join two or more development
histories together
â—‹ git merge [branch-name] - Merge a [branch-
name] with current branch.
End of Day-1
Merge conflicts
â—Ź When two or more people are working on the same file in a repo and are
making changes to it, there are chances that a merge conflict will occur.
â—Ź These conflicts needs to be solved manually by deciding which code to keep
and which code to discard.
Hello_world.txt
User 1 User 2
How collaboration works at software companies?
â—Ź Suppose, the code for an application is hosted on a platform like GitHub.
â—Ź The repository will have 2 branches: Master and Develop
â—Ź Master: This contains the code of application that is currently in production.
â—Ź Develop: This branch has the latest stable code for the application.
● Now let’s see how an employee works when he/she has to add a new feature
to the application.
Scenario
â—Ź Assume that you are an employee working on Instagram Android App.
● And you are asked to work on a feature that allows users to like anyone’s
story.
master develop
master develop
Story-like-feature
Pull Request
â—Ź A pull request is opened to propose some new changes or features.
â—Ź Once a pull request is opened, someone reviews it and suggests some
changes if needed.
â—Ź After few iterations, if everything is good to go then the proposed feature is
merged into master branch.
Practical Demonstration
Visarg
Opening a Pull Request
Raj
Reviewing a Pull Request
Repository Link: https://github.com/DSC-
RNGPIT/git-github-demo
Thank you

Git and github fundamentals

  • 1.
    Git and GithubFundamentals
  • 2.
    What is Git? â—ŹGit is an Open Source Distributed Version Control System (VCS). â—Ź Git was developed by Linus Torvalds in 2005. â—Ź The same person who has developed Linux Operating System.
  • 3.
    What is VersionControl System (VCS) â—Ź 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. â—Ź For an Example: You have created an App which is on 1.0 version. Suppose you want to add a feature and so the App is upgraded to 1.1 version. â—Ź But after few days the app is crashing because of the feature. So now you want to rollback to 1.0 version. â—Ź So here VCS comes into picture. You can track all the changes to file made from particular checkpoint (commit).
  • 4.
    What is Github? â—ŹGitHub is a code hosting platform for version control and collaboration. It lets you and others work together on projects from anywhere. â—Ź Other Alternatives are: Gitlab, Bit-Bucket
  • 5.
    Git Commands â—Ź git--version â—Ź git init â—Ź git add â—Ź git commit â—Ź git status â—Ź git diff â—Ź git log â—Ź git clone â—Ź git remote â—Ź git push â—Ź git pull â—Ź git branch â—Ź git checkout â—Ź git merge
  • 6.
    git --version â—Ź git--version - Returns the version of the git installed on the machine.
  • 7.
    git init â—Ź gitinit - Creates an empty Git repository or reinitialize the existing one.
  • 8.
    git add ● gitadd [filename] - Add file contents to staging area ● git add . - Add all the changed files to staging area. ○ Staging Area - Git knows what files are changed, but doesn’t know why changed.
  • 9.
    git commit ● gitcommit -m “commit message” - Create a new commit containing the current contents of the index and the given log message describing the changes.
  • 10.
    git status â—Ź gitstatus - Show the working tree status. â—‹ Gives the list of files changed
  • 11.
    git diff â—Ź gitdiff - Show changes between commits, commit and working tree, etc â—‹ git diff [filename] - Shows the content changed in file after last commit.
  • 12.
    git log â—Ź gitlog - Shows the commit logs.
  • 13.
    git clone â—Ź gitclone - Clone a repository into a new directory.
  • 14.
    git remote â—Ź gitremote - Adds a remote named <name> for the repository at <url> â—‹ git remote add origin [url]
  • 15.
    git push â—Ź gitpush - Update remote refs along with associated objects. â—‹ git push origin master - update local branch with remote branch.
  • 16.
    git pull â—Ź gitpull - Fetch from and integrate with another repository or a local branch. â—‹ git pull origin master - Fetch from master branch of remote repository and integrate with local branch.
  • 17.
    git branch â—Ź gitbranch - List all the branches â—‹ git branch [branch-name] - Creates a branch with name as [branch-name]
  • 18.
    git checkout â—Ź gitcheckout - Switch branches or restore working tree files. â—‹ git checkout [branch-name] - Checkout to [branch-name] â—‹ Git checkout -b [branch-name] - Creates an checkout to [branch-name]
  • 19.
    git merge â—Ź gitmerge - Join two or more development histories together â—‹ git merge [branch-name] - Merge a [branch- name] with current branch.
  • 20.
  • 21.
    Merge conflicts â—Ź Whentwo or more people are working on the same file in a repo and are making changes to it, there are chances that a merge conflict will occur. â—Ź These conflicts needs to be solved manually by deciding which code to keep and which code to discard. Hello_world.txt User 1 User 2
  • 22.
    How collaboration worksat software companies? ● Suppose, the code for an application is hosted on a platform like GitHub. ● The repository will have 2 branches: Master and Develop ● Master: This contains the code of application that is currently in production. ● Develop: This branch has the latest stable code for the application. ● Now let’s see how an employee works when he/she has to add a new feature to the application.
  • 23.
    Scenario ● Assume thatyou are an employee working on Instagram Android App. ● And you are asked to work on a feature that allows users to like anyone’s story.
  • 24.
  • 25.
    Pull Request â—Ź Apull request is opened to propose some new changes or features. â—Ź Once a pull request is opened, someone reviews it and suggests some changes if needed. â—Ź After few iterations, if everything is good to go then the proposed feature is merged into master branch.
  • 26.
    Practical Demonstration Visarg Opening aPull Request Raj Reviewing a Pull Request
  • 27.
  • 28.