Skip to content

Intro to git lab training (topic branch workflow)

PhillipNordwall edited this page Oct 31, 2014 · 14 revisions

Welcome to the intro to git training lab! We will start by getting everyone into the WWU-ACM Github organization and breaking up into teams. Your team will use on the repositories name in the following fashion WWU-ACM/fa14-team#. This tutorial is the followup from my lecture slides

Step 1: Log in to Linux

If you are in Cygwin on Windows or the terminal in Mac OS then ssh <cs username>@linux.cs.wwu.edu and Linux with us.

Step 2: The WWU-ACM Github organization!

  1. Since we are using Github as our repo host you will need an account. Make one here if you don't have one already.

  2. There will be team lists on the board - go add your Github account name to a team list (3-4 to a team).

  3. You will be added to the WWU-ACM organization and placed in the Intro to Git Lab Team. This team is a Github construct and organization team members have access to repos also added to the team. (The teams on the board correspond to which repo you will be working with)

Step 3: Setting up git on your WWU CS account

  1. Set up your git config.

    git config --global user.name "Your Name"
    git config --global user.email "you@example.com"
  2. Generate an ssh key.

    ssh-keygen # use all defaults (enter enter enter...)
    cat ~/.ssh/id_rsa.pub # copy the output of this
    

    Go to your GitHub ssh key page and add a new key. Use the output of the cat command as your key.

    After that you should be able to verify your key setup with the following command.

    raderk@linux-10:~$ ssh git@github.com
    PTY allocation request failed on channel 0
    Hi kyle-rader! You've successfully authenticated, but GitHub does not provide shell access.
    Connection to github.com closed.
    

Step 4: Topic branch git workflow

Your team's main repo already exists in the WWU-ACM org.

  1. Fork your team's repo on Github.

  2. Clone your forked repo

    git clone git@github.com:your-username/fa14-team#

    Replace your-username with your Github account name and # with your team number.

  3. Change the current directory to your repo.

    cd fa14-team#
  4. Add the upstream remote.

    git remote add upstream git@github.com:WWU-ACM/fa14-team#
  5. Create a branch called add-name.

    git checkout -b add-name
  6. Create this branch on Github.

    git push -u origin add-name
  7. You are now going to add your name to the Names list in the README.md file.

  8. After adding your name git status will show you have un-staged changes. Let's add them interactively with

    git add -p
  9. Now git status will show changes are staged. Let's commit them with

    git commit -m "Added  to the names list."
         git push origin add-name
     
  10. Now on Github you can make a pull request from the branch add-name on your repo to the dev branch of the WWU-ACM's fa14-team# repo.

  11. After this pull request is finished each team member must now update their repo's dev branch.

    git checkout dev
    git pull upstream dev
    git push origin dev
    

    Now we need to rebase the branch add-name.

    git checkout add-name
    git rebase dev  
    // This will cause a merge conflict if you pulled someone else's change.  
    //You now have to fix the merge conflict
    

    If you were the first to get your pull request in then you don't actually need the branch anymore.
    If you are fixing a merge conflict then upon fixing said merge conflict you can submit a pull request or if
    you already have a pull request open it will automatically update with your fix.

This is the basic flow of topic branch development! Congratz you made it!