Git installation and simple application under Linux Ubuntu

Installing Git on the Linux platform

1. The work of Git needs to call  the code of libraries such as curl , zlib, openssl, expat, libiconv, etc., so these dependent libraries need to be installed first. Execute the following command to install the dependent library.
apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev
2. Start to install Git, one command to get it done, as follows:
  apt-get install git
The above two steps are successfully executed, and the installation is completed. You can use git - The -version command checks the version number of Git to confirm that the installation is successful.
 

Note: 1. If you are prompted that you do not have permission when executing the command, please add sudo or enter the root user
           2. Debian and Ubuntu installation commands are consistent

simple application

0. Create a git library
    $ git init
1. View status
    $ git status
2. View file modification
    $ git diff filename
3. View cache modification
    $ git diff --cached filename
4. Restore original file
    $ git checkout filename
5 , Submit the modification
    $ git commit -m "image rotation"
6. View the modification record
    $ git log --oneline -5 .
   -5 ---> View 5 records
7. View the list of modified files
    $ git whatchanged -1 c7b96ab
8 , View the specific modification content of the file
    $ git show c7b96ab filename
9, Generate patch
   1) Generate a patch for a certain record
      $ git format-patch -1 ab87248
    2) Consecutive n items starting from a certain record (Example 5)
      $ git format-patch -5 ab87248
    3) Consecutive n items starting from the first record (Example 5)
      $ git format-patch -5 .
10. Merge into patch
     $ git apply --apply --verbose --reject 0001-VOE-1.3.7.2.patch
     When merging, pay attention to whether there is a *.rej file, which is a conflict file . If so, you need to manually merge in the corresponding modification

11. git add add redundant files undo operation

       1) $git reset HEAD is followed by nothing, that is, all the contents in the last add are revoked
       2) $git reset HEAD XXX is followed by the file name, which is to revoke a certain file
       3) $git restore --staged filename (The function is the same as 2))
12. Exclude the file from the Git project version management
        $git restore filename
13. git commit regrets the undo operation
        $git reset --soft HEAD^
        --soft: Do not delete the workspace to change the code, undo the commit, no Undo git add 
        --hard : delete workspace change code, undo commit, undo git add 

14. The commit comment is written wrong, just want to change the comment, just need:
        $ git commit --amend
        will enter the default vim editor at this time, just save it after modifying the comment.

After remembering the above instructions, the basic functions of Git will be used

Guess you like

Origin blog.csdn.net/weixin_49071468/article/details/130015017