Why You Need Git Inside MetaEditor
If you've ever overwritten a working EA with a broken change and lost hours of work, you already know why version control matters. Until recently, MQL5 developers had to manage code versions manually — copying folders, renaming files, or using external Git clients that didn't integrate with MetaEditor.
MetaQuotes changed that with Algo Forge, the built-in Git system inside MetaEditor. It's not a gimmick. It's a real Git client that lets you commit, branch, push, and pull directly from the editor you already use. You don't need to install anything extra. No command line. No external tools fighting with MetaTrader's file structure.
This guide walks you through the exact setup — from enabling Algo Forge to making your first commit and pushing to a remote repository. By the end, you'll have a repeatable workflow that saves you from losing code and makes collaboration with other developers practical.
What You'll Need Before Starting
Git inside MetaEditor works only with MetaTrader 5 build 4200 or later. Older builds don't have Algo Forge at all. If you're still on MetaTrader 4, you're out of luck — this feature is MT5-only.
Here's the full list of prerequisites:
- MetaTrader 5 — build 4200 or newer. Check your build in Help > About.
- A broker demo account — not strictly required for Git, but you'll need MT5 open and logged in to access MetaEditor.
- A Git hosting account — GitHub, GitLab, Bitbucket, or any service that supports HTTPS Git remotes. Free tier works fine.
- A personal access token (PAT) — most hosting services now require tokens instead of passwords for HTTPS Git operations. Generate one before you start.
- An existing MQL5 project folder — or a new EA you're willing to version. You can use the Experts folder under MQL5 in your MT5 data directory.
If you're unsure where your MT5 data directory lives, open MetaEditor and go to File > Open Data Folder. That's the root. The MQL5 folder inside it is where your code lives.
Step 1: Enable Algo Forge in MetaEditor
Algo Forge is not visible by default in older MetaEditor installations. You have to turn it on.
- Open MetaEditor from MT5: click the MetaEditor icon in the toolbar (looks like a blue book with a pen) or press F4.
- Go to Tools > Options (or press Ctrl+O).
- Select the Algo Forge tab. If you don't see this tab, you're on an older build — update MT5 first.
- Check the box: Enable Algo Forge.
- Optionally check Show Algo Forge panel on startup if you want it visible every time.
- Click OK.
You'll now see a new docked panel on the right side of MetaEditor. It's labeled "Algo Forge" and has tabs for Git, Repository, and History. If the panel doesn't appear, go to View > Toolbars and make sure Algo Forge is checked.
One thing that trips people up: Algo Forge is separate from the Navigator panel. Don't confuse them. Navigator shows your local file tree. Algo Forge shows Git operations.
Step 2: Initialize a Local Git Repository
You can't version control individual files — Git works on folders. You'll initialize a repository inside your EA's project folder.
- In the Algo Forge panel, click the Git tab (the icon that looks like a branch).
- Click the folder icon at the top of the panel — it says "Select Repository Folder" when you hover.
- Navigate to your MQL5 folder, then into Experts, then into the folder containing your EA. For example:
…\MQL5\Experts\MyGridEA - Click Select Folder.
If the folder isn't already a Git repository, MetaEditor will ask: "Initialize a new Git repository here?" Click Yes.
You'll see a .git folder appear in the file tree (it might be hidden in Windows Explorer, but MetaEditor shows it). The Algo Forge panel now shows your repository status. All files in the folder will appear under "Unstaged Changes" — that's normal.
Important: Don't initialize a repository at the MQL5 root level unless you want to version every indicator, script, and include file you have. Keep repositories scoped to individual projects.
Step 3: Configure Your Git Identity
Git needs to know who's making commits. You set this once per repository, or globally if you prefer.
- In MetaEditor, open the Algo Forge panel and click the Git tab.
- Click the gear icon (Settings) in the top-right corner of the panel.
- In the dialog, enter your User name — use your real name or GitHub username. This appears in commit history.
- Enter your Email — use the email you registered with your Git hosting service.
- Click Save.
Alternatively, you can set these globally from a terminal, but MetaEditor's built-in settings are sufficient for most developers. If you skip this step, commits will still work but the author field will be empty — which confuses things when you push to a remote.
Step 4: Make Your First Commit
Now you have a repository. Let's record the current state of your code.
- In the Algo Forge Git tab, you'll see a list of files under "Unstaged Changes". These are files that exist in the folder but aren't tracked by Git yet.
- Click the checkbox next to each file you want to include. Or click the checkbox at the top to stage all files.
- Once staged, the files move to "Staged Changes".
- Below the file list, there's a text field labeled "Commit message". Type something descriptive like "Initial commit — basic grid EA structure".
- Click the Commit button (checkmark icon).
That's it. Your first commit is done. The Algo Forge panel now shows "Nothing to commit" and the History tab will list your commit with its hash, author, and message.
A common mistake: forgetting to stage files before committing. If you click Commit without staging anything, Git creates an empty commit with no changes. That's useless. Always stage first.
Step 5: Connect to a Remote Repository
Local commits are fine for solo work, but you'll want a remote backup and the ability to collaborate. Here's how to push your code to GitHub (or any Git host).
- Create a new empty repository on your Git hosting service. Don't initialize it with a README or .gitignore — you want it completely empty.
- Copy the remote URL. For HTTPS, it looks like:
https://github.com/yourusername/MyGridEA.git - Back in MetaEditor, Algo Forge panel, click the Repository tab (globe icon).
- Click the Add Remote button (plus icon).
- In the dialog:
- Name: origin (standard convention)
- URL: paste the HTTPS URL from your hosting service
- Click Save.
Now you need to push your local commits to this remote. Go back to the Git tab, click the three-dot menu, and select Push. MetaEditor will ask for your credentials:
- Username: your GitHub username (not email)
- Password: your personal access token (not your GitHub password)
If you get an authentication error, you're almost certainly using your account password instead of a PAT. Generate a new token on GitHub (Settings > Developer settings > Personal access tokens > Tokens (classic)) with repo scope. Use that token as the password.
After a successful push, refresh your GitHub page — your code should appear.
Step 6: Basic Git Workflow — Commit, Pull, Push
Once the remote is set, your daily workflow is straightforward:
- Make changes to your EA code in MetaEditor.
- Before committing, click the Pull button (down arrow) to fetch any changes others made. If there are conflicts, resolve them first (see troubleshooting below).
- Stage your changed files (they show under "Unstaged Changes" with a modified icon).
- Write a clear commit message describing what you changed and why.
- Commit.
- Push to remote.
MetaEditor's Algo Forge panel shows file status with icons: green for new, yellow for modified, red for deleted, blue for staged. Learn these — they tell you at a glance what's happening.
Tips and Best Practices
Write Meaningful Commit Messages
"Fixed bug" tells you nothing six months later. Write messages like "Fixed division by zero in calculateLotSize when balance is zero" or "Added trailing stop logic to modifyOrder function". Future you will thank present you.
Use .gitignore
Git tracks everything in the folder unless you tell it not to. MQL5 generates cache files and compiled EX4/EX5 binaries that you don't need in version control. Create a file named .gitignore in your repository root with these contents:
*.ex5
*.ex4
*.cache
Debug/
Release/
MetaEditor doesn't have a built-in .gitignore generator, so create the file in Windows Notepad and save it in your EA folder. Then stage and commit it.
Commit Often, Push When Stable
Local commits are cheap. Commit every time you get a piece working — even if it's not finished. Push to remote only when the code compiles and doesn't crash the terminal. This keeps your remote history clean while giving you local safety nets.
Branch for Experiments
If you want to try a radically different approach (say, switching from martingale to grid logic), create a branch: in the Algo Forge Git tab, click the branch icon and type a new branch name like "feature-grid-logic". Work there. If it works, merge back to main. If it fails, delete the branch and your main code is untouched.
To switch branches, click the branch dropdown in the Algo Forge panel and select the one you want. MetaEditor will update the file tree to match that branch's state.
Common Mistakes and Troubleshooting
Authentication Failed on Push
Symptom: You get "Authentication failed" or "Access denied" when pushing.
Fix: You're using your account password. Generate a personal access token on your Git hosting service and use that as the password. For GitHub, the token needs the "repo" scope. For GitLab, use "read_repository" and "write_repository" scopes.
Nothing Happens When I Click Commit
Symptom: You click Commit but the button doesn't respond or the commit list stays empty.
Fix: You didn't stage any files. Go back to "Unstaged Changes" and check the boxes next to the files you want to include. Then commit.
Merge Conflicts After Pull
Symptom: You pulled from remote and got "Merge conflict in file.mq5".
Fix: MetaEditor doesn't have a visual merge tool. You'll edit the conflicted file manually. The file will have conflict markers:
<<<<<<< HEAD
your local code
=======
remote code from the pull
>>>>>>> commit-hash
Edit the file to keep the correct version (or merge both), remove the markers, save, then stage the resolved file and commit. This is the most error-prone part of using Git in MetaEditor — be careful.
Algo Forge Tab Missing
Symptom: No Algo Forge tab in Tools > Options.
Fix: Your MetaTrader 5 build is too old. Update to build 4200 or newer. If your broker's MT5 build is locked, ask them for an update or install a separate MT5 from MetaQuotes Demo.
Repository Folder Not Showing in Algo Forge
Symptom: You selected a folder but Algo Forge shows "No repository".
Fix: The folder might not be a Git repository. Go to the Git tab, click the folder icon, select the folder again, and answer "Yes" when asked to initialize. If the folder already has a .git subfolder, MetaEditor should detect it automatically.
Summary and Next Steps
You now have a working Git setup inside MetaEditor. You can commit local changes, push to a remote repository, pull updates from collaborators, and switch between branches — all without leaving the MQL5 development environment.
Here's what you should do next to build on this foundation:
- Practice the workflow on a test EA for a few days. Commit after every logical change. Push at the end of each session. The habit is more important than the tool.
- Learn the History tab in Algo Forge. It shows the commit graph, lets you view diffs, and can revert files to previous versions. Right-click any commit to see options.
- Set up a second remote (like GitLab as backup to GitHub) by adding another remote in the Repository tab. Push to both.
- Explore branching more deeply. Create a branch for a feature you're unsure about, work on it, then merge back if it works. This is where Git really shines for EA development.
Version control isn't exciting, but it's the difference between professional development and hoping you don't break something. With Algo Forge, there's no excuse to skip it. Your future self — and anyone you collaborate with — will appreciate the clean history and safety net.
Frequently Asked Questions
Can I use Algo Forge Git with MetaTrader 4?
No. Algo Forge and its Git integration are exclusive to MetaTrader 5 build 4200 and newer. MT4 has no equivalent feature. You'd need to use an external Git client and manually manage the MQL4 folder.
Does Algo Forge support SSH keys for authentication?
No. MetaEditor's Git client only supports HTTPS authentication with username and password (or personal access token). If you need SSH, you must use an external Git client outside MetaEditor.
What happens to my compiled EX5 files in the repository?
By default, Git tracks everything in the folder. Add a .gitignore file (as shown in the tips section) to exclude .ex5, .ex4, and cache files. Otherwise, your repository will bloat with binary files that change every compile.
Can I revert to a previous commit from inside MetaEditor?
Yes. In the History tab of Algo Forge, right-click any commit and select "Revert" or "Reset to this commit". Revert creates a new commit that undoes changes; reset moves the branch pointer back, discarding later commits. Use reset carefully — it rewrites history.






