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
Branch
1. merge main branch to current branch
This is very useful when you work on a branch for a long time, and every day before you start coding, you sync your branch with main
branch.
Suppose you are on the feature-branch
branch, and you want to merge the main
branch to the feature-branch
branch, just use the following command.
1 | git pull origin main |
Move changes from one branch to another
Suppose you made some modifications on branch A
, and you want to move these changes to branch B
, you can use the following command.
If branch B
is existing and has the latest code, you can use the following command.
1 | git switch B # the modification code will automatically bring to branch B |
If branch B
is not existing, you can use the following command.
1 | git stash # save the changes |
git checkout
vs git switch
?
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 -a
to 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 --cached
git 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 Wheel
click)
Yarn
- Input
chrome://settings
in 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