Learning pathway
Version control with Git
- Overview
- About this pathway
- Introduction to version control
- Setting up Git and GitHub
- Version control using Git
- Collaborating on a project using Git
- License and citation
All materials are free cultural works licensed under a Creative Commons Attribution 4.0 International (CC BY 4.0) license, except where further licensing details are provided.
Share this with:
Version control using Git
This is an introduction to the use of the version control tools Git. In particular on how to track files/directories changes and how to navigate in the files and directory history.
Git commands are written as git verb options, where the verb is what we actually want to do and options is additional optional information which may be needed for the verb. git help provide you the list of available git commands. If you forget the subcommands or options of a git command, you can access the relevant list of options typing git <command> -h or access the corresponding Git manual by typing git <command> --help
Learning outcomes
After this module you should be able to:
- Record relevant project changes
- Navigate in the files changes history
- Check the version of your project
Tracking changes using Git
Git commands allow to track files/directories changes in a project and to check the status of a project. 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). This Git cheatsheet shows a graphical representation and can help you understand Git commands.
To commit means that Git takes everything we have told it to save and stores a copy permanently inside the special directory. This permanent copy is called a commit (or revision) and its short identifier is f22b25e. You can refer to commits by their short (e.i. 4ceef11) or full identifiers (e.i 4ceef114b1d92095832623c01c1e1e734918ba9e). You can also refer to the most recent commit by using the identifier HEAD.
- Go through the modify-add-commit cycle for one or more files.
- Explain where information is stored at each stage of that cycle.
- Distinguish between descriptive and non-descriptive commit messages.
Tracking changes using Git
10497
More information about this resourceExploring project history using Git
Using Git commands you can review your changes and restore an old version of your project
- Explain what the HEAD of a repository is and how to use it.
- Identify and use Git commit numbers.
- Compare various versions of tracked files.
- Restore old versions of files.
Exploring project history using Git
10499
More information about this resourceIgnoring files in git repository
Git commands allow you to control for which files/directories you want the changes to be tracked.
- Configure Git to ignore specific files.
- Explain why ignoring files can be useful.