git (2)-general operation of git

 The following content is basically summarized from the second chapter of "git version control management".

git help --all: Get a list of all subcommands. In order to understand the operation of git, we create a new version library, add some content, and then manage some revisions.

2.1, create an initial version library

$ mkdir ~/public_html
$ cd ~/public_html
$ echo 'My website is alive' > index.html

 Run git init to convert ~ / public_html or any directory into a git repository. git init creates a hidden directory .git in the top-level directory of the project, and then puts all the revision information in this directory.

$ git init
Initialized empty Git repository in .git/

2.2, add files to the repository

$ git add index.html

 So far, git has only staged this file. Running the git status command displays the intermediate index.html. Then provide the log of this submission and the author of this change.

$ git commit -m "Initial contents of public_html"   --author="Hanson Joe"

2.3, configuration submission author

 Before committing multiple times to the repository, some basic environment variables and configuration options should be established. git must know your name and email address.

$ git config user.name "Hanson Joe"
$ git config user.email "[email protected]"

 git supports different levels of configuration files, in descending order of priority as follows:

.git/config: The specific configuration settings of the repository can be modified with --file. These settings have the highest priority.
~/.gitconfig: User-specific configuration settings can be modified with the --global option.
/etc/config: System-wide configuration settings with the lowest priority. It can be modified with --system. This file may be in another location or may not exist at all.

 For example: to create an author name and email address, you can use the following command:

$ git config --global user.name "Hanson Joe"
$ git config --global user.email "[email protected]"

In order to set a specific name and email for a repository, only the global flag needs to be omitted. As described earlier.

2.4, view and submit

$ git log
$ git show 9da581d910c9c4ac93557ca4859e76

 git log will generate a series of individual commit history in the repository, listed in order from newest to oldest. git show adds a commit code to view more detailed commit information.

2.5, view the submission differences

$ git diff 9da581d910c9c4ac93557ca4859e76 \
           ec232cddfb94edo65855edf75ack33

2.6. Delete and rename files in the repository

 It is the opposite of adding a file. There are two steps: git rm / git commit, you can also rename a file indirectly through the git rm / git add combination, or you can do it faster with the git mv command:

$ mv foo.html bar.html
$ git rm foo.html
$ git add bar.html
equals to
$ git mv foo.html bar.html

2.7, create a copy of the repository

$ cd
$ git clone public_html my_website

Guess you like

Origin www.cnblogs.com/hansenn/p/12718375.html