Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detach "git gui" started in "Git bash" on Windows?

For example,

  1. I start "git bash";
  2. I navitage to certian directory;
  3. I start git gui&;
  4. I close the console window or press Ctrl+C.

Git-gui's window disappears. Even if I used git gui&disown. Even if it is not in foreground when I pressed Ctrl+C.

How to properly detach git gui from Windows console?

like image 672
Vi. Avatar asked Apr 02 '13 12:04

Vi.


3 Answers

To the benefit of the others I will give a more general answer related to both git bash and msys bash.

Solution 1: Detach without stdout

Assume you want to detach the app:

"C:\Program Files\MyApp\MyApp.exe"

which does not output any info you want to retrieve to stdout (or stderr).
use in your Windows bash shell:

cmd //c start //D "C:\\Program Files\\MyApp"  MyApp.exe arg1 arg2 

MyApp will run in a separate window and closing the calling bash shell will not affect it (by and large like a Linux daemon).

As noted, you can't read app messages unless they are dialog messages, therefore this solution fits to GUI applications. Anyway, if MyApp.exe is instead a Windows batch file like MyApp.cmd, it will call its cmd.exe host and log there: in short you will read outputs for the .cmd/.bat case.

Mac-like users

The cmd.exe window will flash-out for an instant. If this is not such cool for you(r users), in the above line replace cmd with cmdow, NirCmd or the likes.

Solution 2: Detach with stdout

If you want to read logs to stdout and stderr, use:

cmd //c start cmd //k  "C:\\Program Files\\MyApp\\MyApp" arg1 arg2 

This alternative is mostly advised if MyApp is a console application. Now you get a daemon with a "home". MyApp will run hosted by the second cmd.exe and you will see here its output.
For a GUI app you end out with two windows: MyApp window and the calling cmd window.

In both cases, exiting MyApp doesn't mean closing the cmd window; while closing the cmd window will only close MyApp console.

If the flashing punch strikes you, here you only need to replace the first cmd, the second is your daemon's visbile home.

Solution 3: Detach document centric applications

Some documents are closely related to some processing applications, via a mechanism resembling the Linux shebang syntax, but based on Windows' registry; so you open the document without calling the related application.

This behaviour can be emulated in bash and even in a detached style.

As for apps not needing to output to stdout and stderr, opening MyApp.doc with:

cmd //c start //D "C:\\Program Files\\MyApp"  MyApp.exe  "Path\\to\\MyApp.doc"

can be simplified to:

cmd //c start //D "Path\\to" MyApp.doc

As for apps needing stdout and stderr output,

cmd //c start cmd //k  "C:\\Program Files\\MyApp\\MyApp" "Path\\to\\MyApp.doc"

can be reduced to:

cmd //c start cmd //k  "Path\\to\\MyApp.doc"
like image 122
antonio Avatar answered Sep 22 '22 08:09

antonio


The following command works for me from "git bash":

git gui </dev/null >/dev/null 2>&1 &

I tried Ctrl+C, Ctrl+D and simply closing the console window. git gui stayed open in all cases.

like image 42
jeyk Avatar answered Sep 19 '22 08:09

jeyk


If the gitgui is already started, you can disown the job so that it doesn't end with the console:

disown -h <jobid>

If you want to do it when you start Git GUI (so you just launch and forget) there is nohup but for an unknown reason it's not in the binaries distributed by MsysGit

like image 39
CharlesB Avatar answered Sep 22 '22 08:09

CharlesB