Lesson 2. configuration and initializationConfigure git before using git. Git records your name and email address during creation and submission, so you should tell git the content. You can use the 'git config' command to set the parameters. If you pass the '-global' parameter, it records these values in ~ The/. gitconfig file serves as the default value for these configurations. $ Git config -- global user. Name "Scott Chacon"
$ Git config -- global user. Email "schacon@gmail.com" often uses text editors when using git. By default, it uses vim. If you like to use another Editor, such as Emacs, you can set it as follows: $ git config -- global core. you can run the command $ git config user to view the setting value of editor 'ecs. you can also edit the file content by yourself. Git first checks '/etc/gitconfig' and then '~ /. Gitconfig 'the last is '. Git/config'. The content format in these files is similar to this: $ cat ~ /. Gitconfig [user]
Name = Scott Chacon
Email = schacon@gmail.com 2. initialize a new git Repository
Initialize git storage in an existing Directory. You only need to enter the 'git init' command in the directory. This will generate a basic git storage framework for this directory. $ Rails myproject
$ CD myproject
$ Git init now has an empty git storage (you can view the '. Git' directory under the directory ). Now you can use the stage and commit files to this directory. Use the 'git add' and 'git commit 'commands respectively. The following section describes these commands in depth. $ Git add.
$ Git commit-m'initial commit 'so that you have a complete git storage after the commit, and you can run 'git log' (for more information, see the next section) $ git log commit eac2f939e6a1cb3189fedd19919888d998ab0431
Author: Scott Chacon <schacon@gmail.com>
Date: Sun Feb 8 07:55:57 2009-0800 initial commit
Clone a git Repository
Git can communicate over the network through many protocols. Three of the most important protocols are SSH, HTTP, and git (the dedicated git service protocol). Anonymous Access is achieved through git: // or HTTP.
Regardless of the protocol used to clone git storage, the format is as follows: 'git clone url', Uri format:
"Git: // (hostname)/(PATH). Git" $ git clone git: // github.com/schacon/munger.git
$ CD Munger
$ Git log can also be cloned using HTTP. Similar to above, git is replaced with HTTP. $ Git clone
Http://github.com/schacon/munger.gitthis feature is applicable to server support for these two types of agreement. If the server is GitHub, either of the two methods is acceptable.
From http://fsjoy.blog.51cto.com/318484/244803