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

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

Awesome Lists containing this project

README

          

πŸš€ Git Helper Scripts Using PowerShell


Github Repository
Package License
Release Version
Release Version

## 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