zsh - Check if current directory is a Git repository -


I am writing several scripts for GIT management in GST.

How do I check, if the current directory is a GIT repository? (When I'm not in the GET repo, I do not want to execute a part of the command and do not get any bunch of fatal: no GIT repository responses).

The Bash is copied from the complete file is a naive way to do this

  #copyright (c) 2006,2007 Shawn O. Pierce & Lieutenant; Spearce@spearce.org> # Gitcompletion based conceptual (http://gitweb.hawaga.org.uk/) # GNU distributed under General Public License, Version 2.0. If [-d .git]; Then echo .git; Second GIT reverse pars - Git-Dior 2 & gt; / Dev / null; Fi;  

You can either wrap in a function or use it in a script.

Suitable for a bash or zsh, be enclosed in a line condition

  [-d .git] || || Git rev-parse --git-dir> / Dev / null 2 ​​& gt; & Amp; 1  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -