In the Asynchronous Lecture
gitgit checkout & creating alternative realities with branchingIn the Synchronous Lecture
git diff <hash1> <hash2>: compare differences between instances.git log --graph: for a simple visual representation of the git loggitk: for a quick, bare-bones gui.git clone <url>git remotes
git pushgit pull/git fetch.gitignore to ignore files you don’t want to commitgit repositories
git in RStudiogit in AtomIf you have any questions while watching the pre-recorded material, be sure to write them down and to bring them up during the synchronous portion of the lecture.
Slides on best practices for Reproducibility
Practice using git with a git-scavenger-hunt: https://github.com/edunford/git-scavenger-hunt
The following tabs contain pre-recorded lecture materials for class this week. Please review these materials prior to the synchronous lecture.
Total time: Approx. 1 hour and 12 minutes
# Here are the commandline commands we used in the video
cd <directory-path> # Set a working directory
ls # List all files in the working directory
l # List all files + hidden files in the working directory
touch <file-name> # To create a file
# Here are the git commands that we used in the video
git init # to initialize a git repository
git status # to see which files we've staged and git is tracking
git add <file-name> # to add a file to the staging area (to be committed)
git commit -m "" # To create a snap shot of the project (i.e. of all staged files)
git log # To look up the timeline of commits
git log --reflog # To look up the entire timeline (even when we've gone back in time)
git checkout <hash-code> # To go back to a previous moment in the project timeline. # Here are the git commands we used in this video
git commit # To commit staged changes
git checkout <hash> # To checkout a prior snap shot in the project
git branch <name> # To create a new named branch
git branch # To list off all existing branches
git merge <branch-name> # To merge one branch with the current branch# Here are the git commands we used in this video
git commit # To commit staged changes
git checkout <hash> # To checkout a prior snap shot in the project
git branch <name> # To create a new named branch
git branch # To list off all existing branches
git tag <tag-name> # To generate a tag for the specific commit# Here are the git commands we used in this video
git commit # To commit staged changes
git checkout <branch-name> # To checkout branch
git merge <branch-name> # To merge one branch with the current branchOverwhelmed? No worries. git (like most languages) is something you learn best by doing. But here is a cheatsheet to help you along the way. Remember, when programming, cheating is okay! Use Google, use cheatsheets, reference in-class examples — do whatever it takes to learn.
The following survey asks you quick questions regarding the usefulness of the asynchronous lecture materials. Feedback will be used to modify aspect of the asynchronous materials moving forward.
These exercises are designed to help you reinforce your grasp of the concepts covered in the asynchronous lecture material.
Create a folder called “Practice” on your desktop. Next, use the commandline to navigate to that folder. Finally, initialize a git repository in that folder.
cd ~/Desktop/Practice # Navigate to the Practice/ folder you created
git init # Initialize a git repositoryUsing the git repository that you created in Question 1. Do the following:
.txt file using the touch command (or make this file yourself on your compute). Call the file test_file.txt. Add a sentence to this file and then save;git status;# (1) Create a file
touch test_file.txt # Create the file and open it up and add a sentence
# Here is another way to create a file with the sentence included
echo "This is a file" > test_file.txt
# (2) Add file to the staging area
git add test_file.txt
# (3) Double check file is staged
git status
# (4) Commit file
git commit -m "My first commit"
# (5) Update file and commit.
echo "This is a file. New information" > test_file.txt
git add test_file.txt
git commit -m "Updated test_file.txt"
# (6) Look at git log to see commits.
git logUsing the git repository from Q1 & Q2, let’s practice branching and managing merge conflicts.
test_file.txt and commit.master branch.test_file.txt and commit; Make sure that change is to the same line as you change in step 2. Make sure the change differs from what you did in step two.new and master branches.# (1) create and checkout new branch
git checkout -b "new"
# (2) Make a change `test_file.txt` and commit.
echo "This is a file. New information. More info" > test_file.txt
git add test_file.txt
git commit -m "Made change to new branch"
# (3) Check out the `master` branch.
git checkout master
# (4) Make a change `test_file.txt` and commit
echo "This is a file. New information. The cat is black." > test_file.txt
git add test_file.txt
git commit -m "Added material to test_file"
# (5) Now merge the `new` and `master` branches.
git merge new
# (6) Manually resolve the git conflict and then commit the resolved version.
# Do this by openning the file and manually correcting the discrepancy.
git add test_file.txt
git commit -m "managed the merge conflict"
# (7) Look at your git log to see the timeline of changes.
git logThe following materials were generated for students enrolled in PPOL564. Please do not distribute without permission.
ed769@georgetown.edu | www.ericdunford.com