2  Project Management

Many tutorials are available in different formats. Here is a YouTube video ``Git and GitHub for Beginners — Crash Course’’. The video also covers GitHub, a cloud service for Git which provides a cloud back up of your work and makes collaboration with co-workers easy. Similar services are, for example, bitbucket and GitLab.

There are tools that make learning Git easy.

2.1 Set Up Git/GitHub

Download Git if you don’t have it already.

To set up GitHub (other services like Bitbucket or GitLab are similar), you need to

  • Generate an SSH key if you don’t have one already.
  • Sign up an GitHub account.
  • Add the SSH key to your GitHub account

See how to get started with GitHub account.

2.2 Most Frequently Used Git Commands

  • git clone:
    • Used to clone a repository to a local folder.
    • Requires either HTTPS link or SSH key to authenticate.
  • git pull:
    • Downloads any updates made to the remote repository and automatically updates the local repository.
  • git status:
    • Returns the state of the working directory.
    • Lists the files that have been modified, and are yet to be or have been staged and/or committed.
    • Shows if the local repository is begind or ahead a remote branch.
  • git add:
    • Adds new or modified files to the Git staging area.
    • Gives the option to select which files are to be sent to the remote repository
  • git rm:
    • Used to remove files from the staging index or the local repository.
  • git commit:
    • Commits changes made to the local repository and saves it like a snapshot.
    • A message is recommended with every commit to keep track of changes made.
  • git push:
    • Used to send commits made on local repository to the remote repository.

2.3 Tips on using Git:

  • Use the command line interface instead of the web interface (e.g., upload on GitHub)
  • Make frequent small commits instead of rare large commits.
  • Make commit messages informative and meaningful.
  • Name your files/folders by some reasonable convention.
    • Lower cases are better than upper cases.
    • No blanks in file/folder names.
  • Keep the repo clean by not tracking generated files.
  • Creat a .gitignore file for better output from git status.
  • Keep the linewidth of sources to under 80 for better git diff view.

2.4 Pull Request

To contribute to an open source project (e.g., our classnotes), use pull requests. Pull requests “let you tell others about changes you’ve pushed to a branch in a repository on GitHub. Once a pull request is opened, you can discuss and review the potential changes with collaborators and add follow-up commits before your changes are merged into the base branch.”

Watch this YouTube video: GitHub pull requests in 100 seconds.