45 lines
702 B
Markdown
45 lines
702 B
Markdown
# git
|
|
|
|
## discard local changes
|
|
|
|
```bash
|
|
#all unstaged files in current working directory
|
|
git restore .
|
|
|
|
#specific file
|
|
git restore PATH/FILENAME
|
|
```
|
|
|
|
## change origin url
|
|
|
|
```bash
|
|
git remote set-url origin <origin-url>
|
|
```
|
|
|
|
## Create new branch from uncommited
|
|
|
|
```bash
|
|
git switch -c <new-branch>
|
|
|
|
# or
|
|
|
|
git checkout -b <new-branch>
|
|
|
|
```
|
|
|
|
## Credentials
|
|
|
|
```bash
|
|
git config --global credential.helper cache
|
|
|
|
# Cache for 1 hour
|
|
git config --global credential.helper "cache --timeout=3600"
|
|
|
|
# Cache for 1 day
|
|
git config --global credential.helper "cache --timeout=86400"
|
|
|
|
# Cache for 1 week
|
|
git config --global credential.helper "cache --timeout=604800"
|
|
|
|
```
|