Lecture 6

  1. If you don’t have any past experience with Git, either try reading the first couple chapters of Pro Git or go through a tutorial like Learn Git Branching. As you’re working through it, relate Git commands to the data model.
  2. Clone the repository for the class website.
    git clone https://github.com/missing-semester/missing-semester class_website
    1. Explore the version history by visualizing it as a graph.
      git log --all --graph
    2. Who was the last person to modify README.md? (Hint: use git log with an argument).
      git log --all --graph README.md
    3. What was the commit message associated with the last modification to the collections: line of _config.yml? (Hint: use git blame and git show).
      git blame _config.yml

      Hash of the collections: line last modification is a88b4eac.

      git show a88b4eac

      The message is "Redo lectures as a collection"

  3. One common mistake when learning Git is to commit large files that should not be managed by Git or adding sensitive information. Try adding a file to a repository, making some commits and then deleting that file from history (you may want to look at this).
    bfg --delete-files YOUR-FILE-WITH-SENSITIVE-DATA
    If you also want to clean the remote repository:
    git push --force
  4. Clone some repository from GitHub, and modify one of its existing files. What happens when you do git stash? What do you see when running git log --all --oneline? Run git stash pop to undo what you did with git stash. In what scenario might this be useful?
    Running git stash stores the modifications you made and reverts the working directory to the latest commit (no change). git log --all --oneline Won't show the stashed changes because they are stored seperately. git stash pop will revert the working tree back to before git stash.
    This is useful to quickly see what changes you made since the last commit and to write the right commit message. Also it allows you to change branches without having to commit your work or to pull new changes from remote repository without conflictig with local changes.
  5. Like many command line tools, Git provides a configuration file (or dotfile) called ~/.gitconfig. Create an alias in ~/.gitconfig so that when you run git graph, you get the output of git log --all --graph --decorate --oneline. You can do this by directly editing the ~/.gitconfig file, or you can use the git config command to add the alias. Information about git aliases can be found here.
    vim ~/.gitconfig

    boot_time.sh

    [alias]
    	graph = log --all --graph --decorate --online
    						
  6. You can define global ignore patterns in ~/.gitignore_global after running git config --global core.excludesfile ~/.gitignore_global. Do this, and set up your global gitignore file to ignore OS-specific or editor-specific temporary files, like .DS_Store.
    Here are some examples of files you might want to ignore:

    gitignore_globa

    # Ignore zone identifier files (WSL)
    *Zone.Identifier
    
    # Ignore vim swap and backup files
    *.swp
    *.swo
    *.swn
    
    *.bak
    *.backup
    
    # Sensitive SSH and GPG files
    .ssh/
    id_rsa
    id_rsa.pub
    known_hosts
    
    .gnupg/						
  7. Fork the repository for the class website, find a typo or some other improvement you can make, and submit a pull request on GitHub (you may want to look at this). Please only submit PRs that are useful (don’t spam us, please!). If you can’t find an improvement to make, you can skip this exercise.

    The class website has few improvements left to make so you can do this exercise with this website's repository (the site you are currently on).
    This site still has a lot of improvements to make so you don't have any excuse to skip this exercise. This will also give you an opportunity to practice vim.

    If you don't know what to do, you can make the the html files xhtml compatible (especially quotations), add/remove whitespace (both in the files and the website) and add comments to make it more readable, rephrase some of the text so it doesn't look like I was having a stroke when writing it (English is my second language) or add explanations to the exercises I was to lazy to explain completely.

    If I accept your changes, you will also be granted the enormous honor of having your name listed in the contributions section from the about page no one ever looks at!