Welcome to pay attention to the public number: Luka Duo duo

“This is the first day of my participation in the August More Text Challenge.

Git is the beginning of

Git is probably the most common tool we use every day for code updates, submissions, version control, branch switching, etc., providing extremely large traversal for our development. However, I feel that we are still stuck in the stage of Git commit and Git push. Therefore, I am preparing an article about Git technology for the first time.

In fact, you must first sharpen its device —-GIt

The advantages of Git


  • Distributed version control tools
  • Good storage capacity, performance
  • Offline operation
  • Open source
  • Easy to back up
  • It’s easy to customize the workflow

Git official website information

Download address:

git-scm.com/

Check the version

git  --version
Copy the code

Git simple configuration:

Configuring Basic Information

  git   config --global  user.name 'lucas'
  git   config --global  user.email '[email protected]'
Copy the code

Start Configuration 1: View the basic configuration environment:

Git config C:\Users\web>git config usage: Git config [<options>] config file location --global use global config file --system use system config file --local use repository config file --worktree use per-worktree config file -f, --file <file> use given config file --blob <blob-id> read config from given blob object Action --get get value: name [value-regex] --get-all get all values: key [value-regex] --get-regexp get values for regexp: name-regex [value-regex] --get-urlmatch get value specific for the URL: section[.var] URL --replace-all replace all matching variables: name value [value_regex] --add add a new variable: name value --unset remove a variable: name [value-regex] --unset-all remove all matches: name [value-regex] --rename-section rename section: old-name new-name --remove-section remove a section: name -l, --list list all -e, --edit open an editor --get-color find the color configured: slot [default] --get-colorbool find the color setting: slot [stdout-is-tty] Type -t, --type <> value is given this type --bool value is "true" or "false" --int value is decimal number --bool-or-int value is --bool or --int --path value is a path (file or directory name) --expiry-date value is an expiry date Other -z, --null terminate values with NUL byte --name-only show variable names only --includes respect include directives on lookup --show-origin show origin of config (file, standard input, blob, command line) --default <value> with --get, use default value when missing entryCopy the code

Get information about all current configurations:

 git  config --list 
Copy the code

Basic configuration of the warehouse

Git config --list --global Git config --list --system git config --list --localCopy the code

Git configuration user

Git config --global user.email '[email protected]' // Configure the global mail nameCopy the code

Action 2:

Based on the fact that we installed Git directly, and the user and basic configuration of Git have been successful, we started to build the repository of Git configuration, (the file path of code management);

1. Start building Git repository:

You already have your own code — you hand it over to Git to manage

CD Project directory Git initCopy the code

Note: Since the previous configuration was global for GIt, it is generally recommended to configure GIt locally for a specific project repository

Git config --local user.name 'weblucas' git config --global user.email '[email protected]' ## --list --localCopy the code

The warehouse is up and running

2. How to manage test files loaded into Git

Let’s say I create a file called readme

Git add readme 'add new files to git management' git status'Copy the code

New files have been added to the staging area on the branch master

There was actually a command

Git log // see detailed information about this commitCopy the code

But for basic local or global priorities:

  • The current repository is not set, the local setting will be used in the global setting
  • If the local configuration is set locally, the local configuration is preferred as the repository configuration

Case 2:

There is no code, you need to build a warehouse directly to complete the administration

Git staging area

Points to note:

Significance of the existence of temporary storage area:

  • Working directory adjustments, new schema changes – you can commit merges, you can roll back versions
  • Act as a flexible control over code

1. Start file submission and temporary storage

Step 1 Start copying file index;

Git status is displayed after replication

Git status git add file git statusCopy the code

But add a staging area git add

Git add -u indicates that you can directly commit changes to files that are already managed by GitCopy the code

2. Start file renaming:

A step to change the file name

Git commit -m'Copy the code

For basic operations, there are three steps:

Git reset --hard 'deletes all changes in the working directory, staging area'. For example, git log, the data submitted before and the node exists;Copy the code

3. Use Git log to view version evolution history

Git logs are usually used to retrieve all commit history, but they are very special and can be classified

Git log --online 'Display a single git log commit history'Copy the code

Git log -n2 git log -n3 'Copy the code

Git branch -v // How many branches are in the current repository git branch -avCopy the code

Git log --all represents all commits for all branches, and git log represents all commits for the current branchCopy the code
$ git log commit 1b5e86d67c5ab09c0255aa37a847859fc948da12 (HEAD -> master) Author: web <[email protected]> Date: Sun Apr 12 23:43:09 2020 +0800 index+logo commit d9267293d93542109e094dbce3a76d7a12c0bbfc Author: mwbstart <[email protected]> Date: Fri Apr 3 23:15:14 2020 + 0800 'zookeeper and consul as service registry' commit 56 f730e3c78d54ff1674bfd73f2229bf6c8b65ea Author: mwbstart <[email protected]> Date: Thu Apr 2 23:24:48 2020 +0800 SpringCloud's Eureka End (28) web@DESKTOP-DDH479E MINGW64 / d/IDEA2019.3.3 WORKSPACE/springCloud2020 (master) $git log -- all commit 1 b5e86d67c5ab09c0255aa37a847859fc948da12 (HEAD -> master) Author: web <[email protected]> Date: Sun Apr 12 23:43:09 2020 +0800 index+logo commit d9267293d93542109e094dbce3a76d7a12c0bbfc Author: mwbstart <[email protected]> Date: Fri Apr 3 23:15:14 2020 + 0800 'zookeeper and consul as service registry' commit 5 d6448cafb497014aa3ef240662581fb2e227843 (dev) Author: mwbstart <[email protected]> Date: Thu Apr 2 23:47:13 2020 + 0800 had been prohibited to protect themselves commit 4359859 c2a4c4f75ea19860e24255a74aae6ddb1 Author: mwbstart <[email protected]> Date: Thu Apr 2 23:29:39 2020 +0800 'springCloud2020' commit 56f730e3c78d54ff1674bfd73f2229bf6c8b65ea Author: mwbstart <[email protected]> Date: Thu Apr 2 23:24:48 2020 +0800 SpringCloud's Eureka End (28) web@DESKTOP-DDH479E MINGW64 / d/IDEA2019.3.3 WORKSPACE/springCloud2020 (master)Copy the code
Git log --all --oneline --graphCopy the code

Enable Git graphical version evolution history

$git help --web log // The browser becomes a help fileCopy the code

After you create it yourself

new view–> ALL