Git




CS174

Chris Pollett

Oct 26, 2020

Outline

Git

Example Creating a Repository

  • Here is a short example of creating a repository on a *nix system in the directory /Users/cpollett
    mkdir myrepos
    cd myrepos
    git init
    git add .
    echo "hi there" > test.txt
    git add test.txt
    git commit -a -m "Initial commit"
    cd ..
    git clone file:///Users/cpollett/myrepos myrepos2
    cd myrepos2 # now start editing myrepos2
    echo "test2" > test2.txt
    git add test2.txt
    git commit -a -m "Made some changes"
    cd ../myrepos #now want to get changes back in myrepos
    git pull file:///Users/cpollett/myrepos2 master
    
    This produces a copy of the repository in a separate folder. We then edit the copy, and pull the changes back (the changes were in the clone's master branch) into the original repository. We will describe git add and git commit in a moment.
  • If in myrepos2 we had want to get changes from myrepos, we could simply have done:
    git pull
    
    as git will default to pulling where it was cloned from.
  • Creating a WebDav repository

    Configuring your Repository

    Adding, Moving Files

    Committing changes

    We continue to look at how to manage versions of a project in git.

    Quiz

    Which of the following statements is true?

    1. The syntax class A : B, C {} is how in PHP we could say class A is a subclass of class B and class C.
    2. The syntax to indicate that class A uses traits B and C in PHP is:
      class A  {
         use B, C;
         // ...
      }
      
    3. PHP does not support closures.

    Branches, Merging Branches

    Example resolving conflicts

    Making patches