Gust is a PowerShell script that automates common Git tasks for your GitHub repository (managing branches, pushing etc.) with all being configurable in config.json
.
- Verifies if the user has set
user.name
anduser.email
(global and local) - or set their name and email in config with"changeNameGlobal" : true
(default is false) - Initializes a
new
Git repository if one doesn't exists - Adds and commits changes
- Pushes to the selected branch (default is
main
) - A most of things being configurable in
config.json
- Supports multiple "modes" (mode is what the script will do when you run GUST) - including modes: branch switching, branch creating, etc.
- Allows setting default message for commit messages
- Support short aliases for inputs (more on that later)
- Adds a
remote origin
(or any other depends on config) andpulls with --allow-unrelated-histories
Parameter | Required | Description | Aliases |
---|---|---|---|
message | Sometimes | Your commit message you want to use | -c (as commit message) |
gitURL | Only required when initializing repository | The GitHub repository URL (omit .git at the end it will be added automatically) | -u (as URL) |
otherModes | most of the time | This is used to change the mode you want to do, also it has configurable default value "defaultMode" : "c" |
-m (as mode) |
branch | no | this is for working branches, it has default configurable in config under "defaultBranch" : "main", in some cases as main |
-b |
number | no | this is used when you need some number as an input (now it's only used in log, it has default configurable in config "defaultLogLength" : 5, |
-n |
Name | Description |
---|---|
c(commit) | This is configs default. Adds a commit message and pushes to your GitHub repository. |
b(ranch)s(witch)c(create) | Creates a new branch and switches to the new branch. |
b(ranch)s(witch) | Switches to an existing branch. |
b(ranch)d(elete) | Deletes an existing branch. |
s(tatus) | Shows the status of current branch. |
p(ull) | Pulls the latest changes from your remote repository. |
l(og) | Shows recent commits (default number or set with -number / -n). |
{
"defaultBranch" : "main",
"defaultRemote" : "origin",
"userName" : "$null",
"userEmail" : "$null",
"changeNameGlobal" : false,
"autoPullBeforePush": true,
"defaultCommitMessage" : "small fixes",
"forceBranchDelete": false,
"defaultLogLength" : 5,
"defaultMode" : "c"
}
key | description |
---|---|
defaultBranch | Default branch to push to. |
defaultRemote | Default git remote name. |
userName | Used if no git config is set for user.name. |
userEmail | Used if no git config is set for user.email. |
changeNameGlobal | Boolean value that makes the name / email change global or local (to enable name changing you have to change the userEmail to your email address and userName to your name) |
autoPullBeforePush | If True this sets if you automatically pull before pushing. |
defaultCommitMessage | Used as no commit message is inputted. |
forceBranchDelete | If true uses -D (force deletes) branches. |
defaultLogLength | Number of commits shown when using the log mode. |
defaultMode | Default mode used when no mode is inputted. |
- Git installed on your system
- User has configured name and email configured:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
Note: To configure local configuration instead, remove
--global
. Note: this can also be setup as automatic action if you setuserName
,userEmail
to change your name locally, if you want it globally you can change to truechangeNameGlobal
in your config file.
.\gust.ps1 -c "commit message" -u "URL"
This is an example of pushing and setting up remote code to your GitHub repository.
.\gust.ps1 -c "Refactor UI"
This is an example of committing to an already established repository.
.\gust.ps1 -m "bcs" -b "coolBranch"
this is example of creating a new branch and switching to the branch
.\gust.ps1 -m "bs" -b "main"
This is example of switching to a already existing branch.
.\gust.ps1 -m "bd" -b "coolBranch"
This is example of deleting a existing branch.
.\gust.ps1 -m "s"
This is example of showing git status.
.\gust.ps1 -m "log" -n 8
This is example of showing the log provided the length of how much you want (in this you'l see 8 things in the log).
.\gust.ps1 -c "Bug fixes"
This is showcase you don't need to use -m
dor mode because you have default mode in config (which defaults to c
- commit mode).
You can make gust.ps1 callable from anywhere by adding its directory to your PATH environment variable.
For example, if the script is located at: C:\downloads\gust\gust.ps1
Then add the following path to your system's PATH variable: C:\downloads\gust\
Note: last
\
is necesery for it to work
After that, you can run the script using:
gust -c "Your commit message"
Note: If you delete the
gust.cmd
file, you'll need to call the script explicitly usinggust.ps1
. In that case, include the full path or ensure the .ps1 file extension is recognized in your environment.
This was made mainly for my use, because these are most of the commands I use and it streamlines most of my committing to github.