Skip to content

Get MuseScore's source code

riccardoregina edited this page Mar 21, 2024 · 18 revisions

Summary

  1. Create a Projects folder
  2. Fork MuseScore's repository
  3. Clone the repository
  4. Set the remotes

You must have Git installed on your computer (see Set up Developer Environment).

Create a Projects folder

Before you download any source code, it's a good idea to create a folder called Projects, code or src that you can use to store code projects on your machine.

Tips for creating the Projects folder (click to show/hide)
  • For best performance, make sure the Projects folder is located on a modern filesystem that is native to your operating system.
    • Native filesystems: NTFS on Windows, APFS on macOS, BTRFS or EXT4 on Linux.
  • Don't try to share the same Projects folder between different operating systems (e.g. Windows, macOS, Linux) as this can cause corruptions.
    • Sharing between different versions of the same operating system should be OK providing a similar version of Git is used on each.
  • Avoid having spaces, special characters, or non-ASCII characters in any component of the Projects folder's file path.
    • These characters make life difficult on the command line and may cause errors during compilation.
  • Make sure you have read and write permission to the Projects folder and its contents.
    • Never use sudo or "Run as administrator" privileges when compiling code.
  • Don't put Git repositories in a location that is backed up or synced by other software (e.g. Dropbox, OneDrive, Syncthing, etc.).
    • Instead, make commits regularly and push them to a remote repository (your fork) to create a backup.

Linux and macOS

You could create the Projects folder inside your Home directory:

cd ~                # Change (go) to your home directory.
mkdir src           # Create new directory for source projects.

Windows

Create the Projects folder at the root of an NTFS-formatted drive, such as your C: drive:

# Change (go) to the C: drive's root directory:
cd C:\              # PowerShell or CMD
cd /c               # Git Bash

# Create new directory for source projects:
mkdir src

Code projects often contain many layers of subdirectories, so it's best to keep them near the root of the drive to avoid encountering the 260 character MAX_PATH limit Windows places on the length of file paths.

Fork MuseScore's repository

A 'fork' is a remote (online) copy of a repository. After a fork is made, it can be edited freely without affecting the original repository.

Tip: Only create a fork if you want to edit the code. If you just want to compile then you can skip creating the fork and move straight to Clone the repository.

To create a fork:

  1. Sign-in to GitHub (create a free account if necessary).
  2. Visit MuseScore's official repository page: https://github.com/musescore/MuseScore
  3. Click the "Fork" button in the top right to create your personal fork.

Your fork exists at https://github.com/USERNAME/MuseScore where USERNAME is your GitHub username (e.g. shoogle's fork is here).

Clone the repository

A clone is a local (offline) copy of a repository. It's basically a folder on your computer that contains the code for you to edit and/or compile.

If you made a fork then you should clone it here, otherwise clone the official repository. Make the clone inside your Projects folder.

# Go to your source code Projects folder. For example:
cd ~/src            # Linux and macOS
cd C:\src           # Windows - PowerShell or CMD
cd /c/src           # Windows - Git Bash

# Clone your fork if you have one:
git clone https://github.com/USERNAME/MuseScore  # replace USERNAME with your GitHub username

# Otherwise clone the official repo:
git clone https://github.com/musescore/MuseScore

Tip: If you have a fork and you're on Linux or macOS, consider using its SSH URL [email protected]:USERNAME/MuseScore.git instead of the HTTPS URL with the git clone command. This requires additional setup, but it means that you don't have to enter your password every time you push code changes to GitHub. On Windows it's better to use the HTTPS URL if you want the password to be remembered.

Working directory

The git clone command put the code in a new folder called "MuseScore". You should change to it now:

cd MuseScore

This folder is used as the working directory for all subsequent commands, including on subsequent pages of this guide.

Set the remotes

Git is able to push (upload code to) and pull (download code from) remote repositories, known as "remotes".

Run these commands to set the remotes for your local repository:

# If you cloned your fork earlier:
git remote add upstream https://github.com/musescore/MuseScore.git
git remote set-url upstream --push disabled  # Prevent accidental push to official repo (team members only)
git pull upstream master                     # Get latest code from official repo.
git branch -u upstream/master                # Track the official master branch instead of your fork's master branch

# If you cloned the official repo:
git remote set-url origin --push disabled    # Prevent accidental push to official repo (team members only)
Explanation (click to show/hide)

Earlier, when you cloned the repository, a default remote called origin was automatically created. It points to the URL you used with git clone, which was either your fork or the official repository.

When origin is a fork, the convention is to create another remote called upstream that points to the official repository. This is useful later when you want to pull new code from the official repository to keep your fork up to date.

The official repository should only ever be used with pull commands, hence pushing must be disabled on whichever remote represents the official repository. However, it is only necessary for team members to disable it explicitly because GitHub will refuse pushes from users who are not team members anyway.

Tracking the upstream master branch means that git status will show how many commits your local master branch is ahead or behind the upstream master branch.

Use this command to view names and URLs of all remote repositories that Git is aware of:

git remote -v

Hint: You can create additional remotes later on with git remote add [name] [url]. This is useful if you ever need to fetch code from another person's fork.

Testing

Translation

Compilation

  1. Set up developer environment
  2. Install Qt and Qt Creator
  3. Get MuseScore's source code
  4. Install dependencies
  5. Compile on the command line
  6. Compile in Qt Creator

Beyond compiling

  1. Find your way around the code
  2. Submit a Pull Request
  3. Fix the CI checks

Misc. development

Architecture general

Audio

Engraving

Extensions

Google Summer of Code

References

Clone this wiki locally