Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/thisoecode/thisoes-cheatsheet

Thisoe's cmd/bash cheatsheet (mainly `git` and `npm` commands)
https://github.com/thisoecode/thisoes-cheatsheet

Last synced: about 2 months ago
JSON representation

Thisoe's cmd/bash cheatsheet (mainly `git` and `npm` commands)

Awesome Lists containing this project

README

        

# [PINNED]
```bat
git commit -am "[0.1.1] "

git log --oneline

```
[jQuery code](https://code.jquery.com/jquery-latest.min.js)

# npm
### Create new NextJS proj
```bat
:: `cd` to the directory where the proj root folder gonna stay in
npx create-next-app@latest
```

### NextJS preview & test on `localhost:3000`
```bat
npm run dev

npm run build
npm run start
```

### Modify version **_after committed_**
```bat
npm version 0.1.7
```

# Git
### Initialize / Create a repo
```bat
git init
git add .
git commit -am "[0.0.0] "
git remote add origin
git push -u origin main
```

### Use previous commit to create branch
```bat
git checkout -b new_branch_name commit_hash
```

### Create an empty orphan branch
(Old way)
```bat
git checkout --orphan new_branch_name
git rm -rf .
```
([New way](https://stackoverflow.com/a/34100189/23120980))
```bat
git switch --orphan
git commit --allow-empty -m "Initial commit on orphan branch"
git push -u origin
```

### Merge from to "main" branch
```bat
git checkout main
git merge
git checkout app-router
```

### Modify the comment message of last commit
```bat
git commit --amend -m "New message"
```

### List all branch names / List all remote names
```bat
git branch -a
git remote
```

### Delete branch
```bat
git branch -d
git push origin --delete
```

### Find (and switch to) which branch a commit is on using its hash
```bat
git branch --contains
```

### Force push
```bat
git push --force origin
```

### See status of all branches & Push all
```bat
git branch -vv
git status -sb
git push --all
```

### Commit current status in a new branch `temp` and recover `main` branch
```bat
git checkout -b temp
git add .
git commit -m "Temporary commit before reverting errors"
git checkout main
git reset --hard HEAD
:: git push origin temp
```

### Go back to previous commit
See a [safer way](#revert-as-a-new-commit)
```bat
git reset --hard
git reset bc5ca7 --hard
```

### Move `file.txt` from sub-branch to `main` branch (CAUTION: overwrite)
```bat
git checkout --
```

### After changing the repo name on GitHub, change local Git repo's remote URL

1. check the current remote URL
```bat
git remote -v
```

2. change URL
```bat
git remote set-url origin
```

### Revert (as a new commit)
```bat
git log --oneline

git revert --no-commit a1b2c3d..HEAD
git commit -m ""
```

### ...

# Linux Bash (SSH)

### Install Composer
```bash
wget https://getcomposer.org/installer
php installer

composer --version
```
(Composer commands see [#Composer](#composer))

### Install Node
1. Download (Please change the version to needed one)
```bash
wget https://nodejs.org/dist/v20.11.1/node-v20.11.1-linux-x64.tar.gz
tar xvzf node-v20.11.1-linux-x64.tar.gz
mv node-v20.11.1-linux-x64 nodejs
```
2. Move bin file
```bash
mkdir ~/bin
cp nodejs/bin/node ~/bin
```
3. Link
```bash
cd ~/bin
ln -s ../nodejs/lib/node_modules/npm/bin/npm-cli.js npm
```
4. Test command
```bash
node --version
```
5. Enable `npm`
```bash
cd ~/bin
ln -s ../nodejs/bin/npm npm

npm --version
```

# Maven
### clean hook
```bat
./mvnw clean
./mvnw clean
```

### [default]
```bat
./mvnw compile
./mvnw clean test
./mvnw clean package
./mvnw clean verify
```

### something like `npm run dev` on `localhost:8080`
```bat
./mvnw spring-boot:run
```

# Composer
### Add a package
```bat
composer require vlucas/phpdotenv
```

### Install all packages after pulling
```bat
composer install
```

### Show installed packages
```bat
composer show -i
```

### Uninstall a package
```bat
composer remove vlucas/phpdotenv
```