VSCode
Ctrl + P- Search by file nameCtrl + Shift + P- Open command paletteAlt + Left Arrow- Go backCtrl + K, Ctrl + 0- Fold allCtrl + K, Ctrl + J- Unfold all
Angular
Create project with specific version
The following command create angular app with angular 15
1 | npx @angular/cli@15 new my-app |
Git
Checkout a remote branch
For single remote, use the following command.
git fetch– fetch the remote branchgit checkout -b local-branch-name origin/remote-branch-name– checkout the remote branchgit switch -t remote-branch-name– switch to the remote branch, use sgit branch -v -ato make sure your branch is ready.- checkout from tag:
git checkout tags/v1.0.0 -b branch-name
Delete branch
git branch -d branch-name– delete a local branchgit branch -D branch-name– force delete a local branchgit push origin --delete branch-name– delete a remote branch
Diff
Diff staged/indexed changes
git diff --cachedgit status -v– show the changes in the index(staged changes)
2. checkout remote branch
Before checking out a remote branch, you need to fetch the remote branch first.
1 | git fetch |
3. Checkout a specific commit.
The following command will create a new branch from the specific commit, you can find the commit id by git log command or from the git history.
1 | git checkout -b new_branch commit-hash |
Undo
1. Undo last commit
git reset --soft HEAD~1// undo the last commit and keep the changes in working directory.git reset --hard HEAD~1// undo the last commit and remove all changes.
2. Undo staged changes(not committed yet)
git reset HEAD file-name// unstage a filegit reset HEAD .// unstage all files
3. Undo unstaged changes(changes are not added or committed)
git checkout -- .// undo all changes in the working directory, same asgit checkout .?git checkout -- file-name// undo changes in a specific filegit checkout -- '*.js'// undo changes in all js files
4. Undo untracked files
git clean -f// remove untracked filesgit clean -f -d// remove untracked files and directories
git restore和git reset的区别是什么?
Stash
git stash – save the changesgit stash list – list all stashesgit stash apply "stash@{n}" – apply the nth stashgit stash apply n – apply the nth stashgit stash pop – apply the latest stash and remove it from the stash list
Chrome
F12- Open developer toolsCtrl + Shift + P- Open command palette(only works after you open developer tools)Ctrl + P- Open file(after you open developer tools), this is pretty useful when you want to find a file in the source tab.Ctrl+Mouse Left Click- Open a link in a new tab. (also can useMouse Wheelclick)
Yarn
- Input
chrome://settingsin the address bar to open the settings page.
Jest
jest- Run all testjest --coverage- Run test with coverage reportjest --watch- Run test in watch modejest test.spec.ts- Run a specific test filejest test.spec.ts --coverage- Run a specific test file with coverage report
Windows
Win + Shift + S - Take a screenshot