Zoran Pandovski
By Zoran Pandovski

fatal git-write-tree error building trees

fatal git-write-tree error building trees

If you search the above error, most of the answers would be to use git reset --hard command. But, you should be careful with executing this command. You can lose all uncommitted changes from your working tree. So how to resolve this error?

1
2
3
4
5
fatal: git-write-tree: error building trees

Cannot save the current index state

This error usually happens when you have conflicts or unmerged paths. To check the unmerged paths run:

1
2
3
git status

This should show the following message:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$ git status

> # On branch add-helpers

> # You have unmerged paths.

> #   (fix conflicts and run "git commit")

> #

> # Unmerged paths:

> #   (use "git add ..." to mark resolution)

> #

> # both modified:      utilities/helpers.py

> #

> no changes added to commit (use "git add" and/or "git commit -a")

Open the file with conflicts and look for the conflict markers <<<<< and >>>>>. Make the changes you want to keep and then add your changes:


git add utilities/helpers.py

Now, you will be able to commit your changes or switch to another branch.