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.