skip to Main Content

I have some problem with git diff on ubuntu in vs code.
I have prepared some project and devcontainer for it.
The container was build based on python3.11-apline.

When I open the project in normal terminal – i can see all difs in red and green colors. As expected.

In vs code – im opening the project in devcontainer. the git diff or git diff –color – shows all diffs but not highlighted as red or green.

For test I have saved diffs to file and then opened in the same terminal.

git diff --color > foo.txt

cat foo.txt

And all colors appeared!

I have also tried different vscode themes. All the same.

Do you have any idea?

2

Answers


  1. Chosen as BEST ANSWER

    Finally I have found a solution.

    Installing less package resolves the problem:

    apk --update add less in running container or just add the less to the Dockerfile:

    RUN apk update 
        && apk 
        (...)
        less 
        (...)
    

  2. Run git config color.diff in the DevContainer terminal. If it returns auto or always, colors should be enabled. If not, you can enable colors by running git config --global color.diff auto.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search