Some Linux command lines

The command meaning Using the environment CMD corresponding
ls Lists the files in the current directory linux,git base,powershell dir
clear Clear the displayed console contents linux,git base cls
touch aa.txt Create a new aa.txt file linux,git base
rm -fr aaa Forcibly delete aaa files or aaa directories and their subfiles linux,powershell Rd and del
cat cs.js View the contents of the cs.js file linux,git base type
diff a.html b.html Compare A.HTML with B.HTML linux,git base fc
cp cs.txt cs2.txt Copy the file cs.txt to cs2.txt linux,powershell copy
mv cs.txt aaa Move the cs.txt file to the AAA directory linux,powershell move
d: Switch the drive letter to drive D
mkdir aaa Create an AAA folder in the current directory
cd aaa Accessing the AAA Directory
cd .. Back to upper directory
mkdir aaa && cd aaa Create an AAA directory and access the AAA directory
ipconfig /all Check for information such as IP addresses. Note that there is a space between g and /
Ping 192.168.0.1 Ping link, note only domain name or IP address

Vim operations such as

Modify the text content of a file with the vim operation

  1. Ls Displays files or folders accessible to the current directory
  2. Vim. git/config Open the config file in the. Git directory
  3. Move the cursor to the position you want to change and press I to switch insert and replace to insert or overwrite
  4. Press Esc to exit editing
  5. Press Shift +:, type wq, or q! Press Enter to exit Vim

Enter vim < filename > # enter or create a file; All files can be opened by vim. Press I to switch insert and replace

Exit Press Esc to exit editing and press: to enter command input

  • Q Forced exit \
  • Wq Save and exit after entering the code, wq save and exit will enter the check interface to check whether the code conforms to pep8 specifications, and then :q exit directly. \
  • q! Exit without saving

Vim. git/config Open the config file in the. Git directory

\[remotye "origin"]
url = http://xxxname:xxxpassword@...........
Copy the code

Name position fill in the nickname,password fill in git password, so that you do not need to buy a password every time when remote pull replacement.

git

Common Commands

The command meaning instructions
git add -A Commit all changes to the staging area Git add — short for all
git ci -m “xxx” Commit the code for the staging area to the local repository XXX is a description and CI is short for COMMIT
git pull origin br1 Pull code locally from the remote BR1 branch
git push origin br2 Synchronize the local repository to the BR2 branch of the remote repository
git fetch Updating remote branches
git br View all local branches The * will indicate the current branch, and the color will be different
git br -a View all branches of the local remote The red ones are remote branches, and BR stands for branch
git co br1 Switch to the (local) BR1 branch Co is short for checkout, and an error is reported if there is no local BR1 branch
git co -b br3 Create a new BR3 branch and switch to it
git br -D br1 Delete the local BR1 branch
git push origin –delete br1 Delete the remote BR1 branch
git br -m oldBr newBr Change the local oldBr branch name to newBr
git remote -v View the remote corresponding to the local repository
git st View local modified content (including file addition, modification and deletion) Content that is not added is red. Content that is added, but not committed, is green
git co . Undo all file changes and deletions (excluding additions) The result is a file that has not yet been added
git co aa.js Undo changes to a file individually Same as above
git clean -df Undo all new files The result is a file that has not yet been added
git reset . Undoes all content that has been added to the modified, but not yet added, state Applies to files that have been added, but not yet committed
git log Print out all commit records You can view the commitiD and time
git log –pretty=oneline Commit records have been rendered in a friendlier form Only commitiD and remarks can be seen
git reflog Lists records of all Git-related operations The operation ID can be backcoded
git reset –hard id Fall back to a version of the code corresponding to the ID The value can be CommitiD or operation ID
git init Create a.git folder in the current directory This is a hidden folder that contains git configuration files, etc
git remote add origin xxx Associate local and remote repositories Will write content in the.git directory. The XXX suggestion is a link starting with HTTP
git config –user.name “xxx” –global is not recommended, because many times you will have multiple Git accounts Will write to the.git directory
git config –user.email “xxx” –global is not recommended, because many times you will have multiple Git accounts Will write to the.git directory

Git add

  • Git add -a commits all changes
  • Git add -u commits modified and deleted files, excluding new files
  • Git add. submit new and modified files, excluding deleted files

git commit -a

-a saves you a git add step at commit time, but only for modifying or deleting files. New files are still git Add or untracked

Establish a connection between the existing folder and the remote repository

  1. Open the target folder and run git init to generate a. Git directory.
  2. Git config –user.name “XXX” and git config –user.email “XXX” are both optional.
  3. Run git remote add origin XXX to associate the local repository with the remote repository.
  4. Execute git pull Origin master to pull remote code. Git ci -m “XXX”;
  5. You can select Git push -u Origin br1 or Git push Origin br1 for the first remote commit. With -u, you don’t need to add origin master to git pull and git push.

Rollback of files

  • If you have already added git, you can run git reset. Git co 7.js can undo changes or deletions of individual files. Git clean-df can be used to delete newly added files
  • If it has not been added, you can choose git co. Or git clean-df to undo it

Version back

Git reset –hard ID git reflog can be used to restore the commitiD and the operation ID. Git revert is recommended for multiple branches

Git revert and Git Reset

  • Git Revert will create a commit message to undo the changes.
  • Git reset returns the commit directly to the specified COMMIT.

Git pull — Rebase origin br1 merges rebase methods and is more secure

The essence of pull is fetch+merge, which can also be added –rebase merges by rebase

Reference:

  • How do I use Git in my work
  • The Git version is rolled back