Git client installation and use

background

  • For my handsome and dignified blog, I have been researching github, looking around on the Internet, and found the Git client

1. Install github

  • Git is the most advanced distributed version control system in the world, five basic differences between git and svn.
  • git features:
    • Distributed: The Git version control system is a distributed system, a command-line tool used to save the historical state of the project source code;
    • Save point: Git's save point can track the files in the source code, and can get the status of the entire project at a certain point in time; the source code submitted by multiple people can be merged at this save point, or it can be returned to a certain save point Point;
    • Git offline operability: Git can perform code submission offline, so it can be called completely distributed processing, and all Git operations do not need to be performed online; this means that Git is much faster than tools such as SVN, because SVN The tools can only be operated when they need to be online. If the network environment is not good, submitting the code will become very slow;
    • Git is based on snapshots: old-fashioned version control tools such as SVN save the commit point as a patch file, Git commit points the commit point to the project snapshot at the time of the commit, and the committed thing contains some metadata (author, date, GPG, etc.);
    • Git's branching and merging: The branching model is the most notable feature of Git, because it changes the developer's development model. Version control tools such as SVN put each branch in a different directory, and Git can be in the same directory. switch to different branches;
    • Immediate branching: Create and switch branches almost at the same time, users can upload some branches, and other branches can be hidden locally, without uploading all branches to GitHub;
    • Branch flexibility: Users can create, merge and delete branches at any time. Multiple people can implement different functions. They can create multiple branches for development and then merge branches. This way makes development fast, simple and safe.
  1. Download the git client
  2. After downloading, install git

Enter image description

Enter image description

  1. Select the installation path, do not choose the path with Chinese, otherwise it will cause unnecessary misunderstanding

Enter image description

  1. Select the installation components and press the default
  • 1. Icon component (Addition icons): choose whether to create a quick launch bar icon or whether to create a desktop shortcut;
  • 2. Desktop browsing (Windows Explorer integration): The method of browsing the source code, the separate context browsing only uses bash or only the Git GUI tool; the advanced context browsing method uses the git-cheetah plugin plugin;
  • 3. Associate configuration file (Associate .git*): Whether to associate the git configuration file, the configuration file mainly displays the style of the text editor;
  • 4. Associate shell script file (Associate .sh): Whether to associate the script file executed by the Bash command line;
  • 5. Use TrueType encoding: whether to use TruthType encoding in the command line, this encoding is a general encoding developed by Microsoft and Apple;

Enter image description

  1. Set the directory name of the shortcut in the start menu, the default is OK

Enter image description

  1. Set environment variables: choose which command line tool to use, in general, we can use Git Bash by default, which is selected by default;
  • 1. Git comes with: Use the Git Bash command line tool that comes with Git;
  • 2. The system comes with CMD: use the command line tool of the Windows system;
  • 3. Both: The above two are configured at the same time, but note that this will overwrite the find.exe and sort.exe tools in Windows, if you do not understand these, try not to choose;

Enter image description

  1. Select the newline format, it is still the default.
  • 1. Check out the conversion of windows format to unix format: convert the line break in windows format to the line break in unix format before submitting;
  • 2. Check out the original format and convert it to unix format: no matter what format, it will be converted to a newline in unix format before submitting;
  • 3. No format conversion: no conversion, just submit what is checked out;

Enter image description

  1. Select the terminal emulator, still the default is fine
  • 1. Using MinTTY is to open a window Git Bash that simply simulates the Linux command environment in Windows
  • 2. Use the command line program cmd.exe of the Windows system

Enter image description

  1. Just choose the default, no file system cache

Enter image description

  1. Then it can be installed successfully

Enter image description

2. Binding users

  1. Find the installed git package and open git-bash.exe
  • Because Git is a distributed version control system, you need to fill in the username and email as an identifier, and the user and email are the account and email registered with your github

Enter image description

  • PS: git config –global parameter. With this parameter, it means that all Git repositories on your machine will use this configuration. Of course, you can also specify different user names and email addresses for a certain repository.

3. Set SSH key for Github account

  • ssh key is encrypted transmission
    • There are many algorithms for encrypted transmission. Git uses rsa. One of the core problems that rsa needs to solve is how to use a pair of specific numbers, so that one of the numbers can be used for encryption, and the other number can be used for decryption. These two numbers are the public key that you encounter when using git and github, that is, the public key and the private key.
    • Among them, the public key is the number used for encryption, which is why you need to upload the public key to github after you generate the public key locally. The data sent back from github and encrypted with that public key can be restored with your local private key.
    • If your key is lost, whether it is the public key or the private key, you can't use one if you lose one. The solution is very simple, just regenerate it again, and then set it again in github.com
  1. First check whether the secret key cd ~/.ssh has been generated. If the prompt is as shown below, it means that there is no such file.

    Enter image description

  2. If it is not generated, then generate it by $ ssh-keygen -t rsa -C "[email protected]" .

    • 1. It is the path confirmation, just press Enter to save the default path
    • 2. Press the Enter key directly, here we do not use a password to log in, it is too troublesome to use a password;
    • 3. Direct Enter key

Enter image description

  1. If the secret key is generated, ls will see two files, indicating that the secret key has been generated, and id_rsa.pub is the public key

Enter image description

  • It can be found in your computer C:\Users\Administrator.ssh

Enter image description

  1. After the generation is successful, you can view the id_rsa.pub public key file

Enter image description

Fourth, configure ssh_key for the github account

  1. Login to your github, select settings
  2. Then SSH and GPG keys, select the new key, fill in the title, and paste the key in the id_rsa.pub file into this, and then generate the key

Enter image description

  1. The SSH keys configuration of the github account is complete

Enter image description

Five, upload the local project to github

  1. First create several empty folders and a file and a project configuration file on any disk, D:\workspace\2018.3.17public

Enter image description

  1. Instructions for innovating new warehouses
  • git init //Turn this directory into a repository that Git can manage
  • git add README.md //Add the file to the repository
  • git add . //Not only can it follow a single file, it can also follow a wildcard, and it can follow a directory. One point adds all untracked files in the current directory
  • git commit -m "first commit" //Submit the file to the repository
  • git remote add origin [email protected] :wangjiax9/practice.git //Associate the remote warehouse
  • git push -u origin master //Push all the contents of the local library to the remote library
  1. Create a local repository
  2. Enter the 2018.3.17 public project directory, and then execute the command: git init --> When switching to the directory here, remember to use the , slash symbol

Enter image description

  1. After initialization, you will see a hidden folder .git in the project
  • This directory is used by Git to track and manage the repository, but do not manually modify the files in the directory, otherwise the Git repository will be damaged.

Enter image description

  1. Then add all the files to the repository, execute the command: git add .

Enter image description

  1. Submit the file to the repository, the comments are in the double quotes, execute the command: git commit -m "submit the file"

Enter image description

  1. In this way, the local warehouse is established.

6. Associate github repository

  1. Copy the warehouse address to the github tuzi2013 warehouse

Enter image description

  1. Then execute the command: git remote add origin [email protected] :tuzi2013/tuzi2013.github.io.git

Enter image description

Upload local code

  1. Execute the command: git push -u origin master, then type a: yes, then press Enter

Enter image description

  1. In this way, the local code has been pushed to the github repository. We can go to the github repository to view it. After refreshing, we can see the files -> git cannot manage empty folders. There must be files in the folder to add

Enter image description

  1. First create a new test1.html in examples

Enter image description

  1. Execute the instruction to add files -> submit files -> push files
  • git add .
  • git commit -m "commit test1.html"
  • git push -u origin master

Enter image description

  1. Then refresh a github, you will see that the examples folder will come out

Enter image description

  1. Open the folder, test1.html is also inside

Enter image description

  1. This is the foundation built

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325083441&siteId=291194637
Recommended