One, file search

1. Display the absolute path of the current directory

PWD: Print Working Directory

2. View the contents of the current directory

Ls (list)

Note: Ls is not displayed with “by default. A file with a starting filename

3. View the contents of the specified directory

ls /.. /..

4. View the file content

  • cat /.. /..(concatenate) The cat command will display the entire contents of the file
  • head /.. /..The head directive will display the first ten lines of content by default
  • tail /.. /..The tail directive displays the last ten lines of content by default
  • less /.. /..The less command displays a scrollable content, using the J and K keys to scroll up and down, and the Q key to exit

For example, perform the preceding operations on the desktop

λ CD ~/Desktop/ λ PWD /c/Users/yudaza/Desktop λ ls 'Adobe After Effects 2020. LNK '* 'Adobe Photoshop 2020 Ini 'Adobe Audition 2020.lnk'* 'Adobe Premiere Pro 2020.lnkCopy the code

View multiple lines (16 lines) with head or tail directives

λ head 123.css -n 16
λ tail 123.css -n 16
Copy the code

File creation, copy and deletion

1. Create a file

TXT λ echo hello world >> 123. TXT λ echo hello world >> 123. TXT λ echo -e "hello\n front" >> 123.txt λ touch 1.txt 2. TXTCopy the code

The Touch File command creates files

Echo Content > file To add content to a file

Echo new content > file If you enter new content again, the original content will be overwritten

Echo new Content >> file Adds new content to the file

The echo -e directive can activate escape characters

Touch 1txt 2. TXT can create two files at the same time

2. Create a directory

λ mkdir a
λ mkdir -p a/b/c
Copy the code

Mkdir a will create a directory named a

Mkdir -p creates a directory recursively. Even if the upper-level directory does not exist, the system automatically creates a directory at the directory level

3. Copy files and directories

2. TXT λ mkdir a λ -r a bCopy the code

The cp directive copies files

The cp -r command can replicate a directory, and the -r parameter is used for the recursive continuous replication of a directory

Note:-ROnly files in the directory are copied, not folders in the directory

4. Delete files and directories

λ rm 1.txt
λ rm -r a
Copy the code

Rm (remove) : the preceding commands are used to delete files and directories

5. Move or rename files and directories

Mv file file2 Implements the preceding operations

6. Change the last update time of the file

Touch to achieve

Turn commands into files

  • Create a command file with no suffix
Lambda touch commandCopy the code
  • Write the command to be executed to a file (open VScode write command)
Lambda code commandCopy the code
mkdir a
cd a
touch 123.txt
touch 123.js
touch 123.html
Copy the code
  • Add file execution permission (Windows saves this step)
Chmod + x commandCopy the code
  • Execute the Command file
Lambda. / ordersCopy the code
  • To add command to PATH, run the file name

Local warehouse

1. Git six-line configuration

Git config --global user.email git config --global push.default simple git config --global core.quotepath false git config --global core.editor "code --wait" git config --global core.autocrlf inputCopy the code

2. Git version control

2.1. Create a warehouse

  • git initA.git directory is created as a repository

2.2. File staging (trace)

  • Git add pathFiles can be traced (staging area) (path can be absolute/relative path,. Or * path)
  • In VScode, you can create a. Gitignore file and ignore the file names that do not need to be traced, such as node_modules,.DS_Store,. Idea, and

2.3. Submission to warehouse

  • Git commit -m The value is a character stringSubmit to the warehouse. Git (-m: message) git (-m: message)
  • git commit -amCommit tracked (staging area) files to the warehouse. The file is not automatically saved to the staging area when it changes (updates) againgit add file git commit -mBut it’s a bit of a hassle, the above instructions are equivalent to a combination of the two (the premise file has been traced)
  • git commit -vSubmit to the warehouse. — diff (-v: verbose) — diff (-v: verbose)

2.4. Version Information Query

  • git logDisplay current version information (version number and label)
  • git reflogAll version information is displayed

2.5. Version change

  • Git reset -- Hard version numberYou can change the version

3. Multi-version development

  • git branch xCreate a version branch
  • git checkout xGo to the version branch
  • git checkout masterTo the main line

4. Merge versions

  • Go to the branch you want to keep (assume the main branch), and thengit merge x, if there is a conflict between the two version changes, specific changes should be made (delete the unused code, equal sign ====, up and down << and >>), and then submit
  • git status -sbSee which files conflict
  • git branch -d xDelete the branch

5. Remote warehouse

1. Upload the code

  • Create a Github Repo and copy the SSH address
  • git remote add origin git@xxxAdd the remote warehouse address locally
  • git push -u origin masterThe master branch that can push the local master branch to the remote Origin branch. And then you don’t have to-u origin masterSet up the upstream branch
  • git push origin x:xUploading to other branches (local: remote) has the same effect
gti checkout x
git push -u origin x
Copy the code

2. Download the code

  • Git clone git@xxxDownload the code
  • git pullUpdate the downloaded code