Search code examples
gitgit-gui

Git GUI -- how to get back to opening screen


When I launch Git GUI afresh, it gives me the following welcome screen:

enter image description here

Then, after opening one (of many) existing repositories on my local machine, I get to the screen below:

enter image description here

However, from here, I want to go back to the original welcome screen and open a different local repository. That does not seem to be possible. The only options under Repository are:

enter image description here

and none of these help to "Open Existing Repository".

A related question was asked earlier 9 or so years ago here. The answer seemed to suggest that this is a bug in Git Gui. Is it still a bug? Is there a work around?

As of now, if I want to open a different repository, I have no option but to close current running instance of Git Gui followed by opening the Git Gui application again.


Solution

  • This behavior comes from the git-gui.sh which, when it does not detect a $GIT_DIR (.git), will call choose_repository

    set picked 0
    if {[catch {
            set _gitdir $env(GIT_DIR)
            set _prefix {}
            }]
        && [catch {
            # beware that from the .git dir this sets _gitdir to .
            # and _prefix to the empty string
            set _gitdir [git rev-parse --git-dir]
            set _prefix [git rev-parse --show-prefix]
        } err]} {
        load_config 1
        apply_config
        choose_repository::pick
        set picked 1
    }
    

    And git-gui/lib/choose_repository.tcl is the Tcl module which display the "opening screen".

    It is called only from the starting script, and never again.

    This has been set/decided in Sep. 2007, 14 years ago, in commit ab08b36

    git-gui: Allow users to choose/create/clone a repository

    If we are started outside of a git repository than it is likely the user started us from some sort of desktop shortcut icon in the operating system.

    In such a case the user is expecting us to prompt them to locate the git repository they want to work on, or to help them make a new repository, or to clone one from an existing location.

    This is a very simple wizard that offers the user one of these three choices.

    This choice has never been updated seen, so it is not so much a "bug". This seems to be working "as designed".


    WebViewer adds in the comments:

    When Git GUI prompts for "Open Existing Repository", the user should select the directory containing the .git subdirectory, not the .git one.