https://github.com/unacro/gh
Scripts to better use Git
https://github.com/unacro/gh
git powershell
Last synced: 2 days ago
JSON representation
Scripts to better use Git
- Host: GitHub
- URL: https://github.com/unacro/gh
- Owner: unacro
- License: mit
- Created: 2021-05-19T07:55:26.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-06-01T07:44:26.000Z (over 4 years ago)
- Last Synced: 2025-01-21T12:47:27.099Z (11 months ago)
- Topics: git, powershell
- Language: PowerShell
- Homepage:
- Size: 40 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
π Git Helper Scripts Using PowerShell
## Install
```bash
$ git submodule add https://github.com/sumisos/gh.git
```
## Usage
* Configuration file(`.env`) will be generated if not exists
* It also works if moved `ci.ps1` to parent path
```
Your-Project/
βββ .git/ # git repo meta info
βββ gh/
β βββ .env # config file
β βββ core.ps1 # core function
β βββ ci.ps1 # starter
β βββ ...
βββ ... # your project
```
BecomeοΌ
```
Your-Project/
βββ .git/ # git repo meta info
βββ gh/
β βββ .env # config file
β βββ core.ps1 # core function
β βββ ci.ps1 # starter
β βββ ...
βββ ci.ps1 # starter copy
βββ ... # your project
```
`.\gh\ci.ps1` / `.\ci.ps1` will be both effective.
Besides, you can keep it after updated scripts to new version.
**By and large**, content of the `ci.ps1` file would NOT change.
### Configuration `.env`
```
COMMAND_SAVE=save # save func alias
COMMAND_DIST=dist # dist func alias
BRANCH_MAIN=main # old repo is master. nice try. CLM!
AUTO_DELETE= # **CAUTION** auto delete path
ENABLE_GITLAB= # name of another remote repo
DEBUG=false # enable debug mode (log command to console instead of exec)
```
### Windows
```powershell
$ .\gh\ci.ps1 [COMMIT MESSAGE]
```
* ``: `save` or `dist` (you may edit it in `.env`)
* `[COMMIT MESSAGE]`: commit message
#### General
Add untracked files to Staged:
```powershell
$ .\gh\ci.ps1
```
#### Save
Commit changed files & push to remote @ **CURRENT branch**:
```powershell
$ .\gh\ci.ps1 save
```
> Default commit message will be like `Updated @yyyy-MM-dd HH:mm:ss`.
---
You may edit a long commit message (recommend using quotes):
```powershell
$ .\gh\ci.ps1 save "fix: It's a very long commit message & Closes #123, #456"
```
---
You may save the quotes:
```powershell
$ .\gh\ci.ps1 save commit message without special syntax
```
---
You may save the "save":
```powershell
$ .\gh\ci.ps1 s
```
---
It's also support edit commit message:
```powershell
$ .\gh\ci.ps1 sa init
```
#### Distribute
Push `main` branch by merge current branch with keeping in:
```powershell
$ .\gh\ci.ps1 dist
$ .\gh\ci.ps1 d # notice "d" not in "save" because save is first
```
### Linux
```bash
$ chmod +x ./gh/ci
$ ./gh/ci
```
## Update
```bash
$ git submodule update --rebase --remote
```
You may also use update command alias in Windows:
```bash
$ .\gh\ci.ps1 update
```
or in Linux:
```bash
$ ./gh/ci update
```
## TODO
- [x] Support config file to customize script
- [x] Default NOT push to Gitee
- [ ] Refactor shell version to support Linux