cs107-lecture-examples

Example codes used during Harvard CS107 lectures
git clone https://git.0xfab.ch/cs107-lecture-examples.git
Log | Files | Refs | README | LICENSE

setup.sh (821B)


      1 #!/usr/bin/env bash
      2 # File       : setup.sh
      3 # Description: Setup example Git repositories with a remote
      4 # Copyright 2022 Harvard University. All Rights Reserved.
      5 rm -rf git
      6 mkdir -p git/remote
      7 
      8 # initialize remote (bare repository)
      9 (cd git/remote && git init --bare)
     10 
     11 # initialize A
     12 mkdir -p git/A
     13 cd git/A
     14 git init
     15 git config user.name 'Developer A'
     16 git config user.email 'A@domain.org'
     17 git branch -M main
     18 
     19 # setup the remote and create content
     20 git remote add origin ../remote # no URL this time
     21 echo 'Initial' >file
     22 git add file
     23 git commit -m 'Initial'
     24 git push -u origin main
     25 
     26 # B clones
     27 cd .. # inside `git` directory
     28 git clone remote B
     29 cd B # inside repository B
     30 git config user.name 'Developer B'
     31 git config user.email 'B@domain.org'
     32 git config branch.main.rebase 'false'
     33 # default branch name already defined by A