clean-code

Logo

Training materials and slides for courses on version control, clean code and documentation with practical examples and exercises in Python and R

View the Project on GitHub RISE-UNIBAS/clean-code

Git(Hub) core concepts

Repository

A repository is the most basic element of GitHub. They’re easiest to imagine as a project’s folder. A repository contains all of the project files (including documentation), and stores each file’s revision history. Repositories can have multiple collaborators and can be either public or private.

From GitHub glossary/repository

Task 3: Create a repository on with the Github web-interface

Commit

A commit, or “revision”, is an individual change to a file (or set of files). When you make a commit to save your work, Git creates a unique ID (a.k.a. the “SHA” or “hash”) that allows you to keep record of the specific changes committed along with who made them and when. Commits usually contain a commit message which is a brief description of what changes were made.

From GitHub glossary/commit

Task 4: Commit to a repository with the GitHub web-interface

Clone

A clone is a copy of a repository that lives on your computer instead of on a website’s server somewhere, or the act of making that copy. When you make a clone, you can edit the files in your preferred editor and use Git to keep track of your changes without having to be online. The repository you cloned is still connected to the remote version so that you can push your local changes to the remote to keep them synced when you’re online.

From GitHub glossary/clone

Task 5: Sign in to GitHub Desktop

Task 6: Clone a repository with GitHub Desktop

Push

To push means to send your committed changes to a remote repository on GitHub.com. For instance, if you change something locally, you can push those changes so that others may access them.

From GitHub glossary/push

Task 7: Push a commit to remote with GitHub Desktop

Branches

A branch is a parallel version of a repository. It is contained within the repository, but does not affect the primary or main branch allowing you to work freely without disrupting the “live” version. When you’ve made the changes you want to make, you can merge your branch back into the main branch to publish your changes.

From GitHub glossary/branch

Task 8: Create a “new”-branch with the GitHub web-interface

Task 9: Commit to “new”-branch with the GitHub web-interface

Pull

Pull refers to when you are fetching in changes and merging them. For instance, if someone has edited the remote file you’re both working on, you’ll want to pull in those changes to your local copy so that it’s up to date.

From GitHub glossary/pull

Task 10: Switch to “new”-branch with GitHub Desktop

Merge and pull requests

Merging takes the changes from one branch (in the same repository or from a fork), and applies them into another. This often happens as a “pull request” (which can be thought of as a request to merge), or via the command line. A merge can be done through a pull request via the GitHub.com web interface if there are no conflicting changes, or can always be done via the command line.

From GitHub glossary/merge

Task 11: Merge “new”-branch into main via a pull request

Task 12: Delete the “new”-branch with the GitHub web-interface

Optional tasks

Task 13: review a pull request

Task 14: create and resolve a merge conflict