Introduction to Git and GitHub: Glossary

Key Points

Tracking changes with a local repository
  • git init initializes a new repository

  • git status shows the status of a repository

  • Files can be stored in a project’s working directory (which users see), the staging area (where the next commit is being built up) and the local repository (where commits are permanently recorded)

  • git add puts files in the staging area

  • git commit saves the staged content as a new commit in the local repository

  • git commit -a add all tracked files to the staging area, which can be useful when many files need to be updated

  • Always write a log message when committing changes

Looking at history and differences
  • git log shows the commit history

  • git diff displays differences between commits

  • git checkout recovers old versions of files

  • git checkout -b creates a new branch to retain the commits

  • Avoid creating a Git repository within another Git repository

Branching
  • git branch creates a new branch

  • Use feature branches for new ideas and fixes, before merging into master

  • Merging does not delete any branches

Getting started with GitHub
  • GitHub is a remote repositories provider.

  • git push to send local changes to remote repository

  • git clone to make a local copy of a remote repository

Collaborating with a remote repository
  • git fetch to get remote changes and allow inspecting any conflicts with the local commits before proceeding

  • git merge to overwrite local commits with the fetched remote changes

  • git pull executes both fetch and merge, to integrate remote changes into local copy of repository

Pull Requests
  • A fork is a git clone into your (GitHub) account

  • A pull request asks the owner of a repository to incorporate your changes

Glossary

FIXME