10.8 Git Internal Principles-environment variables

Source: Internet
Author: User
Tags command line commit curl glob variables pack parent directory ssl certificate
Environment Variables

Git always runs in a bash shell and uses some shell environment variables to determine how it works. Sometimes it can be useful to know what they are and how they make Git run the way you want it to. All Git environment variables are not listed here, but we will cover the most part. Global Behavior

Like a typical program, Git's general behavior relies on environment variables.

Git_exec_path decides where Git is going to find its subroutines (like Git-commit, Git-diff, etc.). You can use Git--exec-path to view the current settings.

It is not usually considered to modify the HOME variable (too many other things depend on it), which is where Git looks for the global configuration file. If you want a real, portable version of Git that includes a global configuration, you can override the HOME settings in the shell configuration of your portable version of Git.

PREFIX is similar, except for system-level configurations. Git looks for this file $PREFIX/etc/gitconfig.

If Git_config_nosystem is set, the system-level configuration file is disabled. This is useful when the system configuration affects your commands and you do not have permission to modify them.

Git_pager controls The program that displays multi-page output on the command line. If this is not set, it will be used PAGER.

Git_editor when a user needs to edit some text (such as submitting information), Git launches the editor. If not set, you will use EDITOR. Repository Location

Git uses several variables to determine how it interacts with the current repository.

Git_dir is the location of the. Git directory. If this is not set, Git will look up the directory tree by layer up. Git directory until you reach ~ or/.

Git_ceiling_directories controls the behavior of finding. Git directories. If you visit a slow-loading directory (such as those on a tape drive or accessed over a network connection), you might want git to stop trying earlier, especially if the shell was built with git.

Git_work_tree the root path of a non-empty repository's working directory if not specified, the parent directory of the $GIT _dir is used.

Git_index_file is the path to the index file (only non-empty version inject)

The git_object_directory is used to specify the location of the. Git/objects directory.

Git_alternate_object_directories a colon-delimited list (formatted like/dir/one:/dir/two: ...) to tell Git where to find objects that are not in the Git_object_directory directory. If you have many projects with large files of the same content, this can be used to avoid storing too many backups. path Rule

The so-called "pathspec" refers to how you specify the path in Git, including the use of wildcard characters. They will be used in the. gitignore file and will be used in the command line (git add *.c).

Git_glob_pathspecs and Git_noglob_pathspecs Control the default behavior of wildcard characters in path rules. If Git_glob_pathspecs is set to 1, the wildcard character is the wildcard character (this is the default setting); If Git_noglob_pathspecs is set to 1, the wildcard character matches only the literal. This means that *.c only matches files with the file name "*.c", not files ending in. c. You can override this configuration, such as:(Glob) *.c, by starting with:(glob) or:(literal) in each path specification.

Git_literal_pathspecs disables the above two behaviors; the wildcard character will not be used, and the prefix override is not available.

Git_icase_pathspecs let all path specifications ignore the case. Submit

The creation of Git commit objects is usually finally done by Git-commit-tree, and Git-commit-tree uses these environment variables as the main source of information. Fallback to the preset value only if these values do not exist.

Git_author_name is a readable name for the "AUTHOR" field.

Git_author_email is a message in the "AUTHOR" field.

Git_author_date is the timestamp of the "AUTHOR" field.

Git_committer_name is a readable name for the "Committer" field.

Git_committer_email is a message in the "Committer" field.

Git_committer_date is the timestamp of the "committer" field.

If User.email is not configured, it will use the email address specified by email. If this is not set, Git continues to rollback using the system user and host name. Network

Git uses the Curl library to perform network operations over HTTP, so Git_curl_verbose tells GIT to show all messages generated by that library. This is similar to executing curl-v on the command line.

Git_ssl_no_verify tells Git not to validate the SSL certificate. This is sometimes required, for example, if you are using a self-signed certificate to provide a git service via HTTPS, or you are building a git server, and you do not have a full certificate installed.

If the git operation is slower than Git_http_low_speed_limit bytes per second and lasts longer than git_http_low_speed_time seconds, git terminates the operation. These values override the values of the Http.lowspeedlimit and Http.lowspeedtime configurations.

Git_http_user_agent sets the user-agent that Git uses to communicate over HTTP. The default value is similar to git/2.0.0. Compare and Merge

Git_diff_opts This is a bit of a wrong name. Valid values support only-u<n> or--UNIFIED=<N>, and are used to control the number of rows of content displayed in the git DIFF command.

Git_external_diff the value used to override the Diff.external configuration. If you set this value, GIT will call the program when you perform git git diff.

Git_diff_path_counter and git_diff_path_total are useful for Git_external_diff or diff.external specified programs. The former indicates which of the series of files is compared (starting from 1), which represents the total number of files per batch.

The git_merge_verbosity controls the output of the recursive merge policy. The allowed values are the following:

0 Nothing is output, except there may be an error message.

1 only displays conflicts.

2 also shows file changes.

3 is displayed because there are no changes to the skipped files.

4 shows all paths that are processed.

5 Detailed debugging information is displayed.

The default value is 2. Debug

Want to really know what Git is doing? Git has a fairly complete set of tracking information, and all you have to do is turn them on. The available values for these variables are as follows:

"True", "1", or "2" – The tracking category is written to the standard error output.

Absolute path with/start – trace output is written to that file.

Git_trace controls general tracking, and it does not apply to special cases. The scope of the trace includes the expansion of the alias and the delegation of other subroutines.

$ git_trace=true GIT LGA
20:12:49.877982 git.c:554               trace:exec: ' Git-lga '
20:12:49.878369 run-command.c : 341       Trace:run_command: ' Git-lga '
20:12:49.879529 git.c:282 trace:alias               expansion:lga = ' Log '-- Graph '--pretty=oneline '--abbrev-commit '--decorate '--all '
20:12:49.879885 git.c:349 trace:built-in               : git ' log ' '--graph '--pretty=oneline '--abbrev-commit '--decorate '--all ' 20:12:49.899217
run-command.c:341       trace:run_command: ' Less '
20:12:49.899675 run-command.c:192       trace:exec: ' Less '

Git_trace_pack_access Control access tracking information for packaged files The first field is the package file that is accessed, and the second is the offset of the file:

$ git_trace_pack_access=true GIT status
20:10:12.081397 sha1_file.c:2088        . Git/objects/pack/pack-c3fa ... 291e.pack
20:10:12.081886 sha1_file.c:2088.        git/objects/pack/pack-c3fa ... 291e.pack 34662
20:10:12.082115 sha1_file.c:2088        . Git/objects/pack/pack-c3fa ... 291e.pack 35175
# [...]
20:10:12.087398 sha1_file.c:2088        . Git/objects/pack/pack-e80e...e3d2.pack 56914983
20:10:12.087419 sha1_ file.c:2088        . Git/objects/pack/pack-e80e...e3d2.pack 14303666 on
Branch master
Your Branch are Up-to-date with ' origin/master '.
Nothing-to-commit, working directory clean

Git_trace_packet Opening Network Action Pack-level trace information

$ git_trace_packet=
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.