How to fix warning: Support for .git/info/grafts is deprecated in Git

GitADVANCEDMEDIUMUpdated Dec 6, 2025ยท 120 views

This Git warning appears when your repository uses the deprecated grafts file to modify commit history. Git 2.46+ actively warns about this feature, which will be removed in Git 3.0. Convert grafts to git replace refs for a permanent fix.

Quick fix

Fixes warning: Support for .git/info/grafts is deprecated

# View the contents of the grafts file
cat .git/info/grafts

# Show the graft points in your history
git log --oneline --decorate | grep -i graft

# Check how many graft entries exist
wc -l .git/info/grafts
  1. Inspect the current grafts file
  2. Convert grafts to git replace refs
  3. Share replace refs with your team
  4. Remove the deprecated grafts file
git โ€” error
# View the contents of the grafts file
cat .git/info/grafts
# Show the graft points in your history
git log --oneline --decorate | grep -i graft
# Check how many graft entries exist
wc -l .git/info/grafts
warning: Support for .git/info/grafts is deprecated

What this error means

Git grafts were an early mechanism for rewriting commit parentage without modifying the actual commits. By placing entries in the `.git/info/grafts` file, developers could make Git treat certain commits as having different parents than what was recorded in the commit objects themselves. This was commonly used for joining separate repository histories or hiding early commits. However, grafts have fundamental limitations that make them problematic for modern Git workflows. The most significant issue is that grafts are purely local - they exist only in the `.git/info/grafts` file and cannot be shared through push or pull operations. This means every developer on a team would need to manually configure identical grafts, and cloned repositories would have different history than the original. Git marked grafts as deprecated starting with Git 2.18 (June 2018), recommending `git replace` as the modern alternative. Starting with Git 2.46, Git actively displays this warning whenever it detects an active grafts file. The feature is scheduled for complete removal in Git 3.0, making migration essential for any repository still using grafts.

Typical symptoms

  • Warning message 'Support for .git/info/grafts is deprecated' appears during Git operations
  • CI/CD pipelines show unexpected history mismatches or missing commits
  • Cloned repositories have different commit history than the original
  • Git log shows '(grafted)' markers next to certain commits
  • Push operations silently omit commits that should be included
  • Team members see different history for the same repository
  • Shallow clone operations behave unexpectedly near graft points

Common causes

  1. Repository contains an active .git/info/grafts file from legacy history manipulation
  2. Previous attempt to join two separate repository histories using grafts
  3. Historical commits were hidden or orphaned using graft points
  4. Repository was created with SVN-to-Git migration tools that used grafts
  5. Git filter-branch or similar tools left behind graft entries
  6. Manual grafts were added to simulate a different repository history
  7. Legacy scripts or tools created grafts for shallow clone simulation
  8. Repository was upgraded from very old Git versions that relied on grafts

How to fix "warning: Support for .git/info/grafts is deprecated"

1Inspect the current grafts file

First, examine your grafts file to understand what history modifications are in place:

bash
# View the contents of the grafts file
cat .git/info/grafts

# Show the graft points in your history
git log --oneline --decorate | grep -i graft

# Check how many graft entries exist
wc -l .git/info/grafts

Each line in the grafts file has the format: <commit> <parent1> [<parent2>...]. A commit with no parents listed after it becomes a root commit (orphan).

2Convert grafts to git replace refs

Git provides a built-in command to convert all graft entries to replace refs:

bash
# Convert all grafts to replace refs
git replace --convert-graft-file

This command reads each entry in .git/info/grafts and creates a corresponding replace ref. After conversion, Git no longer reads from the grafts file.

Verify the conversion worked:

bash
# List all replace refs
git replace -l

# Show details of a specific replace ref
git replace -l | xargs -I {} git log -1 {}
3Share replace refs with your team

Unlike grafts, replace refs can be shared through Git's normal push mechanism:

bash
# Push all replace refs to the remote
git push origin 'refs/replace/*:refs/replace/*'

For team members to receive the replace refs, they need to fetch them explicitly:

bash
# Configure fetch to include replace refs
git config --add remote.origin.fetch '+refs/replace/*:refs/replace/*'

# Fetch the replace refs
git fetch origin

Add this fetch configuration to your team's setup documentation or onboarding scripts.

4Remove the deprecated grafts file

Once you've verified the replace refs are working correctly, remove the grafts file:

bash
# Backup the grafts file first
cp .git/info/grafts .git/info/grafts.backup

# Remove the grafts file
rm .git/info/grafts

# Verify the warning no longer appears
git status
git log --oneline -5

If you encounter issues, restore from the backup:

bash
mv .git/info/grafts.backup .git/info/grafts
5Make history changes permanent with git filter-repo

For a permanent solution that removes the need for replace refs entirely, use git filter-repo to rewrite history:

bash
# Install git-filter-repo (if not already installed)
pip install git-filter-repo

# Create a fresh clone to work with
git clone --no-local original-repo filtered-repo
cd filtered-repo

# Configure replace refs if not already fetched
git config --add remote.origin.fetch '+refs/replace/*:refs/replace/*'
git fetch origin

# Rewrite history to make replace refs permanent
git filter-repo --force

Warning: This rewrites commit hashes. All team members will need to re-clone the repository after force-pushing.

6Update CI/CD pipelines

If your CI/CD pipelines depend on the modified history, update them to fetch replace refs:

GitHub Actions:

yaml
- uses: actions/checkout@v4
  with:
    fetch-depth: 0

- name: Fetch replace refs
  run: |
    git config --add remote.origin.fetch '+refs/replace/*:refs/replace/*'
    git fetch origin

GitLab CI:

yaml
before_script:
  - git config --add remote.origin.fetch '+refs/replace/*:refs/replace/*'
  - git fetch origin

Consider running git filter-repo to make the history permanent and eliminate the need for these extra fetch steps.

7Verify the migration is complete

Confirm that grafts have been fully migrated and the warning no longer appears:

bash
# Check that grafts file is gone
ls -la .git/info/grafts 2>/dev/null || echo "Grafts file removed"

# Verify replace refs exist
git replace -l

# Run various commands to ensure no warnings
git status
git log --oneline -10
git fsck

# Clone fresh and verify history matches
git clone --no-local . /tmp/test-clone
cd /tmp/test-clone
git log --oneline -10

The warning should no longer appear, and repository history should be consistent across clones.

Advanced notes

### Understanding git replace vs grafts

While grafts simply told Git to pretend a commit had different parents, git replace is more powerful - it can replace any Git object (commit, tree, blob, or tag) with another. When you run git replace --convert-graft-file, Git:

1. Creates a new commit object with the modified parent information
2. Stores a reference from the original commit SHA to the replacement commit
3. Transparently substitutes the replacement whenever the original is accessed

This means the original commits remain intact in the object database, providing a safety net.

### Sharing replace refs in large teams

For organizations with many developers, consider these approaches:

bash
# Option 1: Use a Git template for new clones
mkdir -p ~/.git-template/hooks
git config --global init.templateDir ~/.git-template
# Add a post-checkout hook that fetches replace refs

# Option 2: Include in .gitconfig checked into repo
# In .gitconfig at repo root:
[remote "origin"]
    fetch = +refs/replace/*:refs/replace/*

### When filter-repo is the better choice

Consider using git filter-repo instead of git replace when:

- The repository is relatively small and a full rewrite is feasible
- You want to eliminate the complexity of sharing replace refs
- You're already planning other history cleanup (removing large files, secrets, etc.)
- You need the changes to persist through GitHub/GitLab forks

### Migrating from SVN with grafts

If your grafts were created during SVN migration, the graft points typically mark where svn copy operations (branches) were converted. These are important for maintaining correct git log --follow behavior. Test thoroughly after conversion:

bash
# Test that file history traverses correctly across graft points
git log --follow --oneline -- path/to/frequently-branched-file

### Handling merge conflicts with replace refs

If you have ongoing work based on the old history, you may encounter issues after pushing replace refs. Team members should:

1. Finish and push any in-progress work before the migration
2. Delete local branches and re-fetch them after replace refs are shared
3. Avoid rebasing across the graft/replace boundary

Frequently asked questions

What does "warning: Support for .git/info/grafts is deprecated" mean?
Git grafts were an early mechanism for rewriting commit parentage without modifying the actual commits. git/info/grafts file, developers could make Git treat certain commits as having different parents than what was recorded in the commit objects themselves. This was commonly used for joining separate repository histories or hiding early commits.
How do I fix "warning: Support for .git/info/grafts is deprecated"?
This Git warning appears when your repository uses the deprecated grafts file to modify commit history. Git 2.46+ actively warns about this feature, which will be removed in Git 3.0. Convert grafts to git replace refs for a permanent fix.
What causes "warning: Support for .git/info/grafts is deprecated"?
Repository contains an active .git/info/grafts file from legacy history manipulation Previous attempt to join two separate repository histories using grafts Historical commits were hidden or orphaned using graft points
Is the "warning: Support for .git/info/grafts is deprecated" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading