git-sh-setup - Common Git shell script setup code


   . "$(git --exec-path)/git-sh-setup"


   This is not a command the end user would want to run. Ever. This
   documentation is meant for people who are studying the Porcelain-ish
   scripts and/or are writing new ones.

   The git sh-setup scriptlet is designed to be sourced (using .) by other
   shell scripts to set up some variables pointing at the normal Git
   directories and a few helper shell functions.

   Before sourcing it, your script should set up a few variables; USAGE
   (and LONG_USAGE, if any) is used to define message given by usage()
   shell function. SUBDIRECTORY_OK can be set if the script can run from a
   subdirectory of the working tree (some commands do not).

   The scriptlet sets GIT_DIR and GIT_OBJECT_DIRECTORY shell variables,
   but does not export them to the environment.


       exit after emitting the supplied error message to the standard
       error stream.

       die with the usage message.

       Set GIT_REFLOG_ACTION environment to a given string (typically the
       name of the program) unless it is already set. Whenever the script
       runs a git command that updates refs, a reflog entry is created
       using the value of this string to leave the record of what command
       updated the ref.

       runs an editor of user's choice (GIT_EDITOR, core.editor, VISUAL or
       EDITOR) on a given file, but error out if no editor is specified
       and the terminal is dumb.

       outputs true or false to the standard output stream to indicate if
       the repository is a bare repository (i.e. without an associated
       working tree).

       runs chdir to the toplevel of the working tree.

       checks if the current directory is within the working tree of the
       repository, and otherwise dies.

       checks if the working tree associated with the repository exists,
       and otherwise dies. Often done before calling cd_to_toplevel, which
       is impossible to do if there is no working tree.

   require_clean_work_tree <action> [<hint>]
       checks that the working tree and index associated with the
       repository have no uncommitted changes to tracked files. Otherwise
       it emits an error message of the form Cannot <action>: <reason>.
       <hint>, and dies. Example:

           require_clean_work_tree rebase "Please commit or stash them."

       outputs code for use with eval to set the GIT_AUTHOR_NAME,
       GIT_AUTHOR_EMAIL and GIT_AUTHOR_DATE variables for a given commit.

       modifies the first file so only lines in common with the second
       file remain. If there is insufficient common material, then the
       first file is left empty. The result is suitable as a virtual base
       input for a 3-way merge.


   Part of the git(1) suite


Personal Opportunity - Free software gives you access to billions of dollars of software at no cost. Use this software for your business, personal use or to develop a profitable skill. Access to source code provides access to a level of capabilities/information that companies protect though copyrights. Open source is a core component of the Internet and it is available to you. Leverage the billions of dollars in resources and capabilities to build a career, establish a business or change the world. The potential is endless for those who understand the opportunity.

Business Opportunity - Goldman Sachs, IBM and countless large corporations are leveraging open source to reduce costs, develop products and increase their bottom lines. Learn what these companies know about open source and how open source can give you the advantage.

Free Software

Free Software provides computer programs and capabilities at no cost but more importantly, it provides the freedom to run, edit, contribute to, and share the software. The importance of free software is a matter of access, not price. Software at no cost is a benefit but ownership rights to the software and source code is far more significant.

Free Office Software - The Libre Office suite provides top desktop productivity tools for free. This includes, a word processor, spreadsheet, presentation engine, drawing and flowcharting, database and math applications. Libre Office is available for Linux or Windows.

Free Books

The Free Books Library is a collection of thousands of the most popular public domain books in an online readable format. The collection includes great classical literature and more recent works where the U.S. copyright has expired. These books are yours to read and use without restrictions.

Source Code - Want to change a program or know how it works? Open Source provides the source code for its programs so that anyone can use, modify or learn how to write those programs themselves. Visit the GNU source code repositories to download the source.


Study at Harvard, Stanford or MIT - Open edX provides free online courses from Harvard, MIT, Columbia, UC Berkeley and other top Universities. Hundreds of courses for almost all major subjects and course levels. Open edx also offers some paid courses and selected certifications.

Linux Manual Pages - A man or manual page is a form of software documentation found on Linux/Unix operating systems. Topics covered include computer programs (including library and system calls), formal standards and conventions, and even abstract concepts.