git-for-windows / git

A fork of Git containing Windows-specific patches.
http://gitforwindows.org/
Other
8.43k stars 2.56k forks source link

tig not available to use in terminal after installation #4264

Closed MiguelGuedelha closed 11 months ago

MiguelGuedelha commented 1 year ago

Setup

$ git --version --build-options

git version 2.37.1.windows.1
cpu: x86_64
built from commit: 323a69709944b193bb5cee81ff09fe9a4a686df5
sizeof-long: 4
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
$ cmd.exe /c ver

Microsoft Windows [Version 10.0.22000.1455]
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
  > type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
> type "$env:USERPROFILE\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt

Editor Option: VIM
Custom Editor Path:
Default Branch Option:
Path Option: Cmd
SSH Option: OpenSSH
Tortoise Option: false
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Git Pull Behavior Option: Merge
Use Credential Manager: Enabled
Performance Tweaks FSCache: Enabled
Enable Symlinks: Disabled
Enable Pseudo Console Support: Disabled
Enable FSMonitor: Disabled

No

Details

Powershell

tig

The tig cli tool would run

The tig tool is not found by the OS.

The windows installation of git adds <GitInstallDirectory>/cmd/ into the PATH but tig is contained in <GitInstallDirectory>/usr/bin/

This is not so much a request/issue, but just trying to understand why this tool/path is not also added into the path during installation in order to spare extra manual steps, just to get this tool working globally in the terminal.

dscho commented 1 year ago

I guess the reason is that nobody thought of users yet who would want to launch tig from anything but Git Bash. You can work around this by calling:

git -c alias.tig=!tig tig

If you are interested in making it work out of the box:

  1. install Git for Windows' SDK,
  2. sdk cd mingw-w64-git,
  3. edit mingw-w64-git.mak (to build cmd/tig.exe in addition to compat-bash.exe) and PKGBUILD (to "install" cmd/tig.exe) and create tig.rc, imitating https://github.com/git-for-windows/MINGW-packages/commit/a1d0cf0580688d56aaf9b346051a364d4749d1ff
  4. build the mingw-w64-git package via sdk build
  5. test in-place by copying pkg/mingw-w64-x86_64-git/cmd/tig.exe to /cmd/tig.exe, then prepending C:\git-sdk-64\cmd to your PowerShell's $env:PATH and calling tig from there.
  6. open a PR?
rimrul commented 1 year ago

I guess the reason is that nobody thought of users yet who would want to launch tig from anything but Git Bash.

Well, we kinda did, even before tig. We added the Use Git and optional Unix tools from the Command Prompt option a long time ago. These optional Unix tools include tig nowadays, but of course that option does come with it's own caveats.

dscho commented 1 year ago

of course that option does come with it's own caveats.

@rimrul you might say so... 😁

image

"Only use this option if you understand the implications" is quite scary a warning, and rightfully so.

dscho commented 1 year ago

@MiguelGuedelha I would strongly suggest to look into fixing this (follow the guidance I provided earlier). Not only would this help your use case, it would also help others and therefore make you an Open Source hero.

Chand-ra commented 11 months ago

Hey @dscho, I have created a pull request that solves this issue, thanks to your directions. I tested it as well using this:

test in-place by copying pkg/mingw-w64-x86_64-git/cmd/tig.exe to /cmd/tig.exe, then prepending C:\git-sdk-64\cmd to your PowerShell's $env:PATH and calling tig from there.

and it works as expected. Hopefully this makes me an open source hero :)

dscho commented 11 months ago

Closed via https://github.com/git-for-windows/MINGW-packages/pull/104

jesus2099 commented 9 months ago

In which version of Git for Windows will https://github.com/git-for-windows/MINGW-packages/pull/104 be included in?

I have git version 2.42.0.windows.2 here, but still no tig.exe in cmd folder. And tig command works in Git Bash, but still not in CMD or in PowerShell.

jesus2099 commented 9 months ago

🙇 Sorry sorry sorry!

I have just seen it in some release notes. It seems it means that it will be release in upcoming 2.44 version, or something.

dscho commented 9 months ago

@jesus2099 please try the latest pre-release: https://github.com/git-for-windows/git/releases/tag/v2.44.0-rc1.windows.1

jesus2099 commented 9 months ago

Thanks, I will!