Git Fundamentals Rochelle Terman 13 January 2014
Game Plan 1.Introductions 2.Pedagogy + Plan: See one, do one, teach one 3.Set up: Sign up for Github, Install Git 4.Exercises 1.Pulling / Forking 2.Editing / Commits / Pushing 3.Tracking New Files 4.Fetch / Pull Requests / Collaboration 5.Discussion
3. Signup + Install 1.Go to Sign up if you don’t already have an account 3.Go to help.github.com/articles/set-up-githelp.github.com/articles/set-up-git 4.Follow the instructions to install git 5.(Optional) Follow instructions to set up default address (which should be the same as the you used to sign up to github) 6.Test whether git is working by opening up bash/terminal and typing git
4.1 Forking / Cloning 1.Go to github.com/dlab-berkeley/git-fundamentalsgithub.com/dlab-berkeley/git-fundamentals 2.Fork it by clicking on the “Fork” button on the top right. 3.Open you bash and find your current directory by typing pwd (mac) or %CD% (windows) 4.Migrate to the directory you want to store your git rep by typing cd /path/to/my/git/directory 5.E.g. if you want the desktop, enter: cd ~/Desktop 6.Copy the git clone URL 1.Type git clone
4.1 Forking / Cloning Help pages: 1.Forking + Cloning: (steps 1 and 2) 1.Basic unix commands: current_directory current_directory 1.Basic windows commands: in-Command-Prompt in-Command-Prompt
4.2 Editing / Commits / Pushing 1.Open the README.md file in a text editor (not microsoft word) 2.At the bottom, type in your name followed by your favorite Simpson’s episode, like so: Rochelle: The one where they go to Australia 3.In bash/terminal, migrate to your git rep by typing cd git-fundamentals 4.Type git status 5.To commit, type: git commit –am “ ” 6.To push, type: git push 7.Go back to your forked repo on github and check out what happened.
4.2 Editing / Commits / Pushing Help pages: 1.Creating your own repo (with info on commits + pushing): repo repo 1.Git basics – changing a repo: Recording-Changes-to-the-Repository Recording-Changes-to-the-Repository
4.3 Tracking New Files 1.Create a new txt file and type “TEST” in it 2.Go back to bash/terminal and try to commit your changes. (what happens?) 3.Type git status and note what is says. 4.To add a file for tracking, type: git add or git add. 5.Now commit and push Help: Git basics – adding / ignoring / staging files: the-Repository the-Repository
4.4 Pull / Fetch 1.Go to the d-lab repo (the original repo) you forked and look at the code 2.Navigate to your repo branch and press the green “Compare” button 3.Review your changes and then click the header to submit the pull request 4.To update your local branch, use git pull or git merge Help: Pull Requests: Help: Fetch / merge / pull upstream changes: