# preventing checking out remote branch in gitk

2 messages from 2009-06-05 to 2009-06-06. Participants: Sitaram Chamarty.
Thread: https://gitlist.dev/t/19676

## Sitaram Chamarty, 2009-06-05 15:21

Subject: preventing checking out remote branch in gitk
Message-ID: <slrnh2ie05.8mr.sitaramc@sitaramc.homelinux.net>
URL: https://gitlist.dev/e/slrnh2ie05.8mr.sitaramc%40sitaramc.homelinux.net

```
Hello,

I have a fair number of new users, mostly refugees from VSS
and SVN, and they do use the GUIs a fair bit.

And they keep doing this :-)  I know what you're thinking:
teach them not to do it...

But doing this at the command line gives you a nice warning,
and a GUI is (like it or not) considered more "safe" (aka
less powerful).  So it should go one better and just refuse
:-)

Is there any way we can disable "Checkout this branch" for
branches that are not local in gitk?  I'm willing to play
around with the code and test it if someone can give me a
couple of pointers at least.

Thanks,

Sitaram

```

## Sitaram Chamarty, 2009-06-06 04:06

Subject: [PATCH] gitk: disable checkout of remote branch
Message-ID: <slrnh2jqqr.64k.sitaramc@sitaramc.homelinux.net>
URL: https://gitlist.dev/e/slrnh2jqqr.64k.sitaramc%40sitaramc.homelinux.net
In-Reply-To: <slrnh2ie05.8mr.sitaramc@sitaramc.homelinux.net>

```
At the command line, this gives you a detailed warning message, but the
GUI currently allows it without any fuss.

Since the GUI is often used by people much less familiar with git, it
seems reasonable to make the GUI more restrictive than the command line,
not less.

This prevents a lot of detached HEAD commits by new users.

Signed-off-by: Sitaram Chamarty <sitaramc@gmail.com>
---

I have a lot of new users, and I'd really appreciate it if
someone could review (hey it's my first Tcl code in all my
life!) and approve; this will save me a whole boatload of
trouble :-)

If someone disagrees with the logic that the GUI should be
more "safe" than the command line please do let me know.

 gitk-git/gitk |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
 mode change 100644 => 100755 gitk-git/gitk

diff --git a/gitk-git/gitk b/gitk-git/gitk
old mode 100644
new mode 100755
index 8c66d17..411bc52
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -8770,6 +8770,9 @@ proc headmenu {x y id head} {
     set headmenuid $id
     set headmenuhead $head
     set state normal
+    if {[string match "remotes/*" $head]} {
+	set state disabled
+    }
     if {$head eq $mainhead} {
 	set state disabled
     }
-- 
1.6.3.2

```
