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

Setting up ssh keys (GitHub authentication)

do you have ssh keys?

ls -al ~/.ssh

If "no such file" then create them

ssh-keygen -t ed25519 -C "<your email>"

save to default file

if group resource set a passphrase

ls -l
cat ~/.ssh/id_ed25519.pub

Identify your public and private key

Setting up ssh keys (GitHub authentication)

  • Add ssh keys to GitHub
  • Click on your picture --> settings
  • On left select SSH and GPG keys
  • Add new ssh key
  • Save
  • Test your set up
ssh -T git@github.com

Create a new repository

  • Press the create a new repo button
  • Call your repo planets and "create repository"
  • Follow the directions to push an existing repository
  • put up your green post-it

Connect your remote and local repositories

  • 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 main

Exercise: Explore your remote repository

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

More information

  • what branch am I on?
    •  
    • default: main
    • if you are not on the main branch, switch to it
  • 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

Starting your collaboration

  • Start a DM on slack and say hi to each other
  • Decide who is Dracula and who is Wolfman
  • You will be using Dracula's repository
  • put up your green post-it

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 SSH
  • cd into the planets directory you just downloaded
  • put up your green post-it
git clone git@github.com/

Dracula: adding a collaborator

  • Anyone can clone only collaborators can write
  • Dracula only:
    • Click settings in the top bar menu
    • Click collaborators on the LHS
    • Add Wolfman's github username where it says find a collaborator
    • Wolfman accept the the invitation via email or via the inbox icon on GitHub

Github

Remote repository

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 main
git pull origin main

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: 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
  • Wolfman: save, 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

Title Text

  • Bullet One
  • Bullet Two
  • Bullet Three

Update the your copy of the class repository

  • cd to your home directory (cd ~)
  • cd to the class repository:
    • cd 2023-01-07-aas-swc
    • git pull origin gh-pages

collaborating_using_git

By abostroem

collaborating_using_git

  • 3,013