In digital musicology, we often work with files that change over time:
A common problem is that files get copied, renamed, emailed around, or stored as:
final.xmlfinal_revised.xmlfinal_revised2.xmlfinal_REAL_final.xmlThis quickly becomes confusing.
Git helps us keep a structured history of changes. GitHub makes it easier to synchronize work between computers and collaborate with others.
For musicological editorial work, this is especially useful because:
After this introduction, students should be able to:
Git is a version control system.
This means it records the history of a folder and its files over time.
With Git, you can:
Git is not only for programmers. It is useful for any research project where files evolve over time.
GitHub is a web platform built around Git.
Git itself works on your computer. GitHub adds:
A useful short formula is:
A repository (or „repo“) is a project folder managed by Git.
It contains:
A commit is a saved snapshot of your work.
A commit should record a meaningful step, for example:
A remote is an online copy of your repository, for example on GitHub.
This lets you:
A branch is a parallel line of work.
Branches are useful when:
Git works especially well when files are text-based.
MEI files are XML, so Git can track line-by-line changes very well.
This means Git can help you see:
Git works best with plain text files:
.mei.xml.csv.txt.md.pyGit works less well with large binary files such as:
.pdf.docx.png.jpg.tifThis does not mean you cannot store such files in a repository, but:
What is needed:
For long-term understanding, command line Git is better. For quick adoption, GitHub Desktop may be easier.
Mei-friend has a sophisticated GitHub integration which we'll probably use most of the time, but git syntax is universally usable in all tools/environments.
After installing Git, set your name and email in the terminal:
git config --global user.name "Your Name" git config --global user.email "your.email@example.org"
This identifies your commits.
Check the configuration:
git config --global --list
Move into your project folder:
cd path/to/music-edition-project
Initialize Git:
git init
Now Git is tracking this folder as a repository.
The most important command for beginners is:
git status
This shows:
Students should get used to running git status very often.
To prepare all current changes for a commit:
git add .
To add one specific file:
git add data/mei/motet_01.mei
After adding files, save a snapshot:
git commit -m "Corrected note durations in motet_01"
A good commit message is:
Good examples:
Corrected mensuration encoding in KyrieNormalized staff labels in source BFixed barline errors in movement 3Added editorial note on unclear accidentalsBad examples:
changesupdatestufffinalCreate an empty repository on GitHub.
Then connect your local repository to it:
git remote add origin https://github.com/USERNAME/REPOSITORY.git
Check that the remote was added:
git remote -v
If your main branch is called main:
git branch -M main git push -u origin main
After that, future uploads are usually just:
git push
Before you start working, download any new changes:
git pull
This is especially important if:
git pull git status git add . git commit -m "Describe the editorial change" git push
This can be explained as:
pull before workstatus to inspect changesadd to stage themcommit to record thempush to synchronize themWhen multiple people work on one repository, Git can help organize collaboration.
A simple shared workflow:
For slightly more advanced collaboration, use:
Branches are useful when you want to try something without changing the stable version.
Example uses:
Create a new branch:
git checkout -b revise-source-A
Work and commit as usual.
Later, the branch can be merged into the main branch.
A merge conflict happens when Git cannot automatically combine two competing changes.
Example:
This is normal and not a disaster.
The usual solution is:
For beginners, the best prevention is:
Useful GitHub features include:
Use issues to track:
A pull request lets someone propose changes before merging them.
This is useful for:
GitHub also allows you to inspect file history and see who last changed a line.
This can be very helpful when asking:
| Term | Meaning |
|---|---|
| Git | Version control system |
| GitHub | Online platform for hosting Git repositories |
| Repository | A project folder tracked by Git |
| Commit | A saved snapshot of changes |
| Push | Upload local commits to GitHub |
| Pull | Download changes from GitHub |
| Branch | A separate line of development |
| Merge | Combine changes from different branches |
| Conflict | A situation where Git cannot automatically combine changes |