Resources for the Git portion of the 2018-03-29-stanford Software Carpentry workshop.
- Introduction to Git and GitHub
- Setting Up Git
- Creating a repository (we will create repositories using GitHub, but these instructions detail an alternative way to create a repo from the command line
- Tracking Changes
- Ignoring Things
- Exploring History
- Capstone Project
Which command(s) below would save the changes of myfile.txt
to my local Git repository?
$ git commit -m "my recent changes"
$ git init myfile.txt $ git commit -m "my recent changes"
$ git add myfile.txt $ git commit -m "my recent changes"
$ git commit -m "my recent changes" myfile.txt
The staging area can hold changes from any number of files that you want to commit as a single snapshot.
Add some text to mars.txt
noting your decision to consider Venus as a base
Create a new file venus.txt
with your initial thoughts about Venus as a base for you and your friends
Add changes from both files to the staging area, and commit those changes.
Add some useful info to the README.md
file for the planets repo.
Commit the changes
Push the changes to GitHub
Create a new Git repository on GitHub called bio
.
Clone the repository to your computer.
Write a three-line biography for yourself in a file called me.txt
, commit your changes
Modify one line, add a fourth line, commit your changes
Push the changes to GitHub
How would you ignore all .data
files in your root directory except for final.data
? Hint: Find out what !
(the exclamation point operator) does
Given a .gitignore
file with the following contents:
*.data
!*.data
What will be the result?
Jennifer has made changes to the Python script that she has been working on for weeks, and the modifications she made this morning “broke” the script and it no longer runs. She has spent ~ 1hr trying to fix it, with no luck. Luckily, she has been keeping track of her project’s versions using Git! Which commands below will let her recover the last committed version of her Python script called data_cruncher.py
?
$ git checkout HEAD
$ git checkout HEAD data_cruncher.py
$ git checkout HEAD~1 data_cruncher.py
$ git checkout <unique ID of last commit> data_cruncher.py
Both 2 and 4
- Create new repository
- Write shell script to [practice something from shell]
- Commit script and push to GitHub
- Write shell script to [practice something else from shell]
- Commit script and push to GitHub
- Clone your neighbor's repo from GitHub and look at their scripts