Learning Version Control with GitHub
- Part 1: Why Use Version Control?
- Part 2: Using GitHub
- Part 3: Working with Repositories
- Part 4: Markdown and Code
- Part 5: Managing Repositories
Working with Repositories
Repositories are collections of files. When changes are downloaded locally, they are pulled. Changes sent to the repository are pushed.
When a push is made, it is called a commit. This is a user “committing” their changes to the repository.
On GitHub, all commits are given a unique identifiers. Each commit is tracked across the project and helps other contributors know that certain changes are associated with that user.
When using the GitHub Desktop application, one of the more common activities is to pull the latest changes. In the application, this is called fetch. Clicking it will download any changes to the repository made since last checked and will update the local files.
Adding a file to the local folder will cause the GitHub Desktop application to update. It will show the latest changes and the textual content of those files.
All commits require a summary and an optional description. These help other users know why these changes were made and how they contribute to the overall project. Often, it is useful to write a longer description for multiple or larger changes to better help understand what is going on in the project and in regard to the changes.
Once the “Commit to master” button is clicked, the commit is ready to be pushed. The GitHub Desktop application will show at the bottom that a new commit as been created and is ready to be pushed. To do that, click on “Push origin” to upload those new changes.
Note: By default, all commits go the “master” branch of the project. Creating and using branches are part of a later section.
Returning to GitHub in a web browser shows the new files (if any), the commit they are a part of, and when they were changed.
Clicking on the name of a commit shows what was changed. As shown in the GitHub Desktop application, any additions (green) or deletions (red) will be shown.
When viewing a repo on the GitHub website, one of the options is to view the commits made to that project.
Clicking on “Commits” shows a listing of all changes during the lifetime of the project, who made then, when they were made, and what was changed.
While a pull is not tracked, all pushes and commits are tacked by GitHub and can be used to monitor a project, seeing who made which changes, when those changes were made, and how those changes affected the overall project.