Collaborating using github

Remote repository

  • central location everyone can see
  • requires internet
  • github, bitbucket
  • public vs private

Sign into github

  • go to github.com
  • sign into your account
  • Put up a green post-it

Create a new repository

  • Press the + sign and select "New Repository
  • Call your repo planets and "create repository"
  • Follow the directions to push an existing repository
  • put up your green post-it
  • Copy and Paste this section into the terminal where you created your local repository
  • remote add... gives the nickname 'origin' to the url to the remote repository
  • git push -u ... creates remote branch on origin called master

Connect your remote and local repositories

Exercise: Explore your remote repository

  • at the top of the page click yourname/planets
  • Explore...

More information

  • what branch am I on?
    •  
    • default: master
  • what is my remote repository?
    •  
    • default nickname: origin
git branch
git remote -v

Starting your collaboration

  • Find a partner
  • Decide who is Dracula and who is Wolfman
  • You will be using Dracula's repository
  • put up your green post-it
  • put up your red post-it if you need a partner

Wolfman: Cloning a repository

  • cd out of planets, create a new directory called planets_collab, and cd into it
cd ../
mkdir planets_collab
cd planets_collab
  • Clone Dracula's repository
  •  
    • make sure its set to HTTPS
  • cd into the planets directory you just downloaded
  • put up your green post-it
git clone https://github.com/...

Dracula: adding a collaborator

  • Anyone can clone only collaborators can write
  • Dracula only:
    • Click settings on the RHS
    • Click collaborators on the LHS
    • Add Wolfman's github username under collaborators

Wolfman: Accept Dracula's invitation

You should receive an email or notification on GitHub that you've been invited to join Dracula's repository. Accept this invitation

1. Dracula

  • modify mars.txt
  • save your changes
  • add and commit your changes
  • push your changes to the remote repository

2. Wolfman

  • pull down your partner's changes
    •  
  • add a line to the end of mars.txt
  • save your changes
  • add and commit your changes
  • push your changes to the remote repository

Collaborating

git push origin master
git pull origin master

Merge without conflict

  • Dracula: modify the first line of mars.txt, save, add, and commit
  • Wolfman: modify the last line of mars.txt, save, add, and commit
  • Dracula: pull down changes from Wolfman
    • you will be asked to save a merge commit message in nano
      • ctl+x
  • Dracula: push your changes to the remote repository
  • Wolfman: pull down changes from Dracula and save the commit message
  • Wolfman: push your changes to the remote repository

Merge with conflicts

  • Dracula: Before you pull down Wolfman's changes, edit the last line of the mars.txt, save, add, and commit
  • Dracula: try to pull down changes from the remote repository

Resolving Conflicts

  • Dracula: open mars.txt
  • Dracula: edit mars.txt to look like correct file
    • remove extra text
    • choose which lines you want to keep
  • Dracula: save, add, commit, push

Exercise: Repeat for Wolfman

  • Wolfman: pull down Dracula's changes
  • Dracula: change the first line of jupiter.txt
  • Dracula: save, add, commit, push
  • Wolfman: change the first line of jupiter.txt, add, commit
  • Wolfman: pull down Dracula's changes
    • you will get a conflict
    • open jupiter.txt and edit to look like final version
    • save changes to jupiter.txt
    • add, commit, push

Update the your copy of the class repository

  • cd to your home directory (cd ~)
  • cd to the class repository:
    • cd 2019-01-05-aas
    • git pull origin gh-pages
Made with Slides.com