Git Intro for Librarians: Reference

Key Points

What is Git/GitHub?
  • Git and Github are not the same

Getting started with git
  • git repositories are data-structures used to track changes to files over time

  • Git uses a two-stage commit process. Changes must first be added to the staging area, then committed from there

Sharing your work
  • remote repositories on GitHub help you collaborate

  • push is a Git verb for sending changes from the local repository to a remote repository

  • pull is a Git verb for bringing changes from a remote repository to the local repository

Review
  • the workflow isn’t tricky, but it the language takes some time to settle in

Github Pages
  • GitHub Pages use the Git/GitHub workflow to help you build webpages

Quick reference

Basics - navigating the shell

pwd
print working directory
ls
list directory :
  • -l: list file information
  • -lh: list human readable file information
cd
change directory

Basics - interacting with files

mkdir
make directory
cat
send file or files to output (in most cases, print to shell)
head
output first parts of a file or files
tail
output last parts of a file or files
mv
rename or move a file or files. Syntax for renaming a file: mv FILENAME NEWFILENAME
cp
copy a file or files. Syntax: cp FILENAME NEWFILENAME
>
redirect output. Syntax with cat: cat FILENAME1 FILENAME2 > NEWFILENAME
rm
remove a file or files. NB: USE WITH CAUTION!!!

Basic Git commands

Git cheat sheet handouts:

git init
creates a git repository
git status
view the status of your files in the working directory and staging area
git add
tells git to start tracking a file, or a series of files.
git commit
commits ‘saves’ the staged snapshot to the project history.
git push
commits the staged snapshot to the project history.
git log
history of commits in reverse chronological order.
git diff
shows changes made to files
git pull
Merges upstream changes into your local repository
git remote add origin
add a repository where changes will be stored -

Useful library github repositories

Further reading