Running Git through Cygwin from Windows

前端 未结 4 1568
孤独总比滥情好
孤独总比滥情好 2020-12-02 11:30

I have started using Cygwin recently for other purposes and already have Git installed on my PC. I understand I can run the executable and install Git into Cygwin, but since

相关标签:
4条回答
  • 2020-12-02 11:52

    I confirm that git and msysgit can coexist on the same computer, as mentioned in "Which GIT version to use cygwin or msysGit or both?".

    1. Git for Windows (msysgit) will run in its own shell (dos with git-cmd.bat or bash with Git Bash.vbs)
      Update 2016: msysgit is obsolete, and the new Git for Windows now uses msys2

    2. Git on Cygwin, after installing its package, will run in its own cygwin bash shell.

    git package selection on Cygwin

    1. Finally, since Q3 2016 and the "Windows 10 anniversary update", you can use Git in a bash (an actual Ubuntu(!) bash).

    In there, you can do a sudo apt-get install git-core and start using git on project-sources present either on the WSL container's "native" file-system (see below), or in the hosting Windows's file-system through the /mnt/c/..., /mnt/d/... directory hierarchies.

    Specifically for the Bash on Windows or WSL (Windows Subsystem for Linux):

    • It is a light-weight virtualization container (technically, a "Drawbridge" pico-process,
    • hosting an unmodified "headless" Linux distribution (i.e. Ubuntu minus the kernel),
    • which can execute terminal-based commands (and even X-server client apps if an X-server for Windows is installed),
    • with emulated access to the Windows file-system (meaning that, apart from reduced performance, encodings for files in DrvFs emulated file-system may not behave the same as files on the native VolFs file-system).
    • Unfortunately, it cannot invoke back into Windows executables, or
    • interact with any native drivers (i.e. so no Graphic card, no USB drives yet).
    0 讨论(0)
  • 2020-12-02 11:52

    Isn't this as simple as adding your git install to your Windows path?

    E.g. Win+R rundll32.exe sysdm.cpl,EditEnvironmentVariables Edit...PATH appending your Mysysgit install path e.g. ;C:\Program Files (x86)\Git\bin. Re-run Cygwin and voila. As Cygwin automatically loads in the Windows environment, so too will your native install of Git.

    0 讨论(0)
  • 2020-12-02 11:53

    I can tell you from personal experience this is a bad idea. Native Windows programs cannot accept Cygwin paths. For example with Cygwin you might run a command

    grep -r --color foo /opt
    

    with no issue. With Cygwin / represents the root directory. Native Windows programs have no concept of this, and will likely fail if invoked this way. You should not mix Cygwin and Native Windows programs unless you have no other choice.

    Uninstall what Git you have and install the Cygwin git package, save yourself the headache.

    0 讨论(0)
  • 2020-12-02 12:10

    call your (windows-)git with cygpath as parameter, in order to convert the "calling path". I m confused why that should be a problem.

    0 讨论(0)
提交回复
热议问题