Alternatives to Git for Windows

    At the moment (beginning of April 2015) the “official” version of Git for Windows is 1.9.5 , while version 2.3.5 is already available for all other platforms. Hence the natural interest in updating Git for Windows to the current version or replacing it with an alternative distribution.

    After a little research, the following methods (distributions) of using Git on the Windows platform were discovered.

    Git for Windows.


    The distribution offered on the official git-scm website is based on the MSYS project. That is, in fact, it is ported to Windows Git, plus a subset of the GNU utilities needed for Git to work.

    Among the shortcomings are the outdated version of Git and other GNU utilities. For several years, requests for updating utilities ( perl , ssh , ...) have been hanging in the bugtracker .

    There are no utilities I need (rsync, ...). They have to be borrowed from the MSYS project, which does not always work (different versions, sometimes incompatible with each other).

    At the moment, the project is moving to another base - MinGW-w64 + MSYS2. Developers uploaded Developer's Preview version, but at the time of verification, the ssh utility was missing from it, and the problem with adding other utilities seems to remain. But GNU utilities have been updated to current ones, especially perl.

    A selection of utilities from the MinGW-builds project


    This assembly was discovered almost by accident, in the process of finding a more recent version of GCC. Contains all the utilities I need. But, unfortunately, has not been updated for a long time.

    Msys2


    I learned that there is an independent MSYS2 project from messages on the bug tracker of the git-for-windows project. From the pros:
    • MSYS independent project
    • uses MinGW-w64,
    • uses the Pacman package manager ported from Arch Linux (more stable and functional, unlike the mingw-get hack),
    • Fresh utilities
    • git is present in packages
    • there is a 64-bit version.

    Of the minuses, probably a larger size when installed by default, compared to Git for Windows. But extra packages can be removed.

    EGit / JGit


    Eclipse Git implementation (in Java). It is possible to invoke from the command line, but MSYS shell is required, and this is more a proof-of-concept than a normal way of working.

    SmartGit / Hg


    This is also a native implementation of Git in Java. There is no normal ability to work on the command line. And so, a great tool, there is an Open Source License.

    libgit2


    A very promising project. It is made initially portable, the implementation is on pure C. But so far there are no projects that implement all the functionality of Git (GUI + command line) using only this library.

    Projects:
    • Git-GUI - alpha version, no command line.
    • Github for windows - uses Git for Windows for the command line.

    The posh-git project can also be noted here , but as I understand it, it also requires that Git is already accessible from the command line.

    Cygwin


    In contrast to the MSYS , sells (or trying to) a complete POSIX layer for applications. I am more impressed with the MSYS approach. When used, it seemed to me more heavy compared to MSYS.

    Total


    Stopped on MSYS2. I liked the fact that Git is made in the form of a package (with dependencies, etc.), as well as the presence of fresh GNU utilities that are easy to install from packages.

    Next will be described: comments that appeared during operation, possible difficulties and solutions.

    Installation


    1. Download 32-bit or 64-bit MSYS2. Yes, now there is 64-bit Git, comments about it below.

    There should be no spaces in the name of the installation folder (and path), and there should be only ASCII characters (ASCII, no accents, spaces nor symlinks, short path). In the future, I will refer to this folder as% MSYS2_DIR%.

    After the installation is complete, launch MSYS2 Shell (Start → All Programs → MSYS2).

    2. Install and update MSYS2 packages (described in more detail here , or here with pictures ):

    pacman -Sy
    pacman --needed -S bash pacman pacman-mirrors msys2-runtime
    

    Restart MSYS2 Shell and run % MSYS2_DIR% \ autorebase.bat for the 32-bit version. Further

    pacman -Su
    

    3. Configure HOME

    By default, the HOME folder is created in % MSYS2_DIR% \ home \% USERNAME% , and % MSYS2_DIR% \ etc \ skel files are copied to it , as described in % MSYS2_DIR% \ etc \ post-install \ 05-home- dir.post . It is possible to configure the folder HOME =% USERPROFILE% . To do this, move all files from% MSYS2_DIR% \ home \% USERNAME% to % USERPROFILE% and correct the line "db_home: cygwin desc" in the file % MSYS2_DIR% \ etc \ nsswitch.conf to "db_home: windows desc"

    perl -pi.orig -e "s/db_home:\s+cygwin\s+desc/db_home: windows desc/" nsswitch.conf
    

    If the HOME variable already exists, then files from % MSYS2_DIR% \ etc \ skel will not be copied anywhere. If necessary, copy them manually, and / or update .bashrc and other files.

    4. Install Git

    pacman -S git
    

    Customization


    1. To add autocompletion (by Tab) of Git commands and additional information to the command prompt, copy the files:

    %MSYS2_DIR%\usr\share\git\completion\git-completion.bash  -> %HOME%\.git-completion.bash
    %MSYS2_DIR%\usr\share\git\completion\git-prompt.sh        -> %HOME%\.git-prompt.sh
    

    In the % HOME% \. Bashrc file add the lines

    . ~/.git-completion.bash
    . ~/.git-prompt.sh
    PS1='\[\033]0;$MSYSTEM:${PWD//[^[:ascii:]]/?}\007\]'    # set window title
    PS1="$PS1"'\n'                                          # new line
    PS1="$PS1"'\[\033[32m\]'                                # change color to green
    PS1="$PS1"'\u@\h '                                      # user@host
    PS1="$PS1"'\[\033[33m\]'                                # change color to yellow
    PS1="$PS1"'\w'                                          # current working directory
    if test -z "$WINELOADERNOEXEC" ; then
      PS1="$PS1"'$(__git_ps1)'                              # bash function
    fi
    PS1="$PS1"'\[\033[0m\]'                                 # change color to normal
    PS1="$PS1"$'\n'                                         # new line
    PS1="$PS1"'$ '                                          # prompt: always $
    

    The git-prompt setting ( PS1 variable ) is taken from previous versions of Git for Windows.

    Pay attention to PS1 = "$ PS1" $ '\ n' . The expression $ '\ n' is used to fix a bug
    It seems like $ () style command substitution for some reason always fails in MSYS2 if a newline is present after it.

    2. Documentation

    Manpages will be installed by the git package. To view it, you will need the man-db package:

    pacman -S man-db
    

    And then, as usual

    man git-add
    

    No HTML documentation yet

    git help add
    fatal: '/usr/share/doc/git/html': not a documentation directory.
    

    Accordingly, you can try to build it yourself , or extract it from the PortableGit archive and copy it to % MSYS2_DIR% / usr / share / doc / git / html .

    Git 32bit vs. 64bit


    During the operation of 64bit Git, an increased memory consumption was found for some commands. For example, when converting a large repository (of the order of 5GiB), git-fast-import easily ate all the available RAM (when the paging file is disabled, this manifests itself as a system message saying that the application does not have enough memory and is asked to close the program). For the same (already converted) repository, TortoiseGit Log could not display the commit tree, and the running git subprocess again ate all the RAM.

    For 32bit Git, this was not observed, and all the teams, including in conjunction with various GUIs and IDEs, worked perfectly.

    I decided to use Git 32bit for now.

    Also popular now: