Git: Unsafe repository is owned by someone else (Windows)

After updating git the following message appeared during opening the repository with SourceTree:

I tried out two different possibilities to solve this problem. First, I added the recommended command from the error message

git config --global --add safe.directory <repo-path>

This solution works fine but has the big impact that changing the repository path afterwards would lead to the same error again. So I removed the entry from

C:\Users\<username>\.gitconfig

and I found out that a better soluation would be to adapt the security settings for the repository in Windows by performing the following steps:

  • Open Windows “Explorer” and go to the repository where the error occurred
  • Right click on the repository directory and select “Properties”
  • Open the “Security” tab and click on “Extended”
  • Change the “Owner” in the top of the window to your user account

For me this worked perfectly and I didn’t need to set the repository on the safe list of the global git configuration.

Docker in Hyper-V Image

Using Docker in a Hyper-V image can be that easy – if you know how to do that. The use case is quite simple: imagine you have a company or private infrastructure that runs on a server. This server runs multiple instances of Windows (Server) where one instance is used for developing and another for testing. Now if the assignement is to create a Docker image that runs your application than you might have the same problems that I had – I didn’t work on a fast try. So here is the short and simple solution of a few hours of trying and searching.

Preferences Hyper-V Host

  1. Start Hyper-V-Manager
  2. Write down name of the image that should run Docker for Windows
  3. Download the following script
    https://github.com/MicrosoftDocs/Virtualization-Documentation/blob/live/hyperv-tools/Nested/Enable-NestedVm.ps1
  4. Open powershell as Administrator
  5. Execute script
powershell -ExecutionPolicy Bypass -File .\Enable-NestedVm.ps1 {Hyper-V-image-name-that-should-run-Docker}

Explaination
-ExecutionPolicy Bypass: by default, no one is allowed to execute unsigned scripts, so bypass this setting. Just try it out without this parameter and you will see the response.
-File: the file to execute

Preferences Hyper-V Image

  1. Enable Windows Features
    + Containers
    + Hyper-V
  2. Download
    https://docs.docker.com/docker-for-windows/install/
  3. Install Docker
  4. Concratulation, you successfully installed Docker in a Hyper-V image!

Windows Qt Maintenance Tool Stucks Solution

Sometimes it happens, that the maintenance tool of Qt is running and running and nothing is happening. It stucks at 99% and I waited hours of hours. In my case the following helped me to overcome this:

  1. Open Windows Explorer and enable the following option: show hidden files and folders
  2. Be sure that the maintenance tool is not running in the background (TaskManager)
  3. Now clear the following folder (it should contain ‘remoterepo-*’ – folders)
    C:\Users\profile-name\AppData\Local\Temp\
  4. Finished. Now open the Qt Maintenance tool and try again to update or modify your packages.

Visual Studio 2015 CE and GitLab

Here is a small example of how you can use Visual Studio 2015 CE with Gitlab:

  1. Create a new project in GitLab and clone it to your local file system. Notice you will need the http link to your project in a later step.
  2. Open Visual Studio 2015 CE and create a new project in the cloned directory. VS 2015 CE will automatically detect the git version control.
  3. Go to the Team Explorer register tab and follow these steps:
    vs2015_ce_git_1
    Next open the the Repository Settings by clicking on the combobox in the top area of the register card.
    vs2015_ce_git_2
    Go to the Remotes section and ente your GitLab projectlink from step 1.
    vs2015_ce_git_3
    Go to the Changes section and make a comment to the included files.
    vs2015_ce_git_4
    If all is successfully configured you can now go to the Synchronization section and sync, fetch, pull or push your project.
    vs2015_ce_git_5
Congratulation! You managed to use Visual Studio 2015 CE with your GitLab repository!

TortoiseGit and GitLab

Here are the steps to use TortoiseGit with GitLab:

  1. Create a new project or use an existing one und notice the SSH link, e.g.
    git@SERVER:user/test.git
  2. Create secret keys with puttygen
    C:\Program Files\TortoiseGit\bin\puttygen.exe
    puttygen_1
    a) Press Generate
    b) Move mouse in the empty area until key has been generated
    c) Save public and private key (fill out Key passphrase)
    d) Copy public key from the Public key for pasting into OpenSSH… area
  3. Log into your GitLab site and go to your Profile settings menu, select the SSH Keys button and paste your copied public key in the empty area. Save your profile.
  4. Select local repository folder, right click and select Git clone. Fill out the form like this example below:
    Gitclone_1
    Press OK (and enter your Key passphrase from your private key)
Congratulation! You successfully configured your TortoiseGit with GitLab!