git_aliases provide short-hands for git. Immensely are the functions written for saving the time of each developer. git
works on any POSIX-compliant shell (sh, dash, ksh, zsh, bash), in particular on these platforms: unix, macOS, and windows WSL.
Only works with git
, please be sure it should be installed on the machine.
apt install git
To install or update, you should run the install script. To do that, you may either download and run the script manually or use the following cURL or wget command:
curl -o- https://raw.githubusercontent.com/vulrun/git-aliases/v1.2-beta/install.sh | bash
wget -qO- https://raw.githubusercontent.com/vulrun/git-aliases/v1.2-beta/install.sh | bash
Running either of the above commands downloads a script and runs it. The script downloads the script to $HOME
generally at ~/
, and attempts to add the source lines from the snippet below to the correct profile file (~/.bash_profile
, ~/.zshrc
, ~/.profile
, or ~/.bashrc
).
-
If the environment variable
$XDG_CONFIG_HOME
is present, it will place the.git_aliases
file there. -
You can customize the install source, directory, profile, and version using the
XYZ_SOURCE
,XYZ_DIR
,PROFILE
, andNODE_VERSION
variables. Eg:curl ... | NVM_DIR="path/to/git-aliases"
. Ensure that theNVM_DIR
does not contain a trailing slash. -
The installer can use,
curl
, orwget
to download.git_aliases
, whichever is available.
To verify that git-aliases has been installed, do:
git-aliases
which should output aliases version, if the installation was successful. Please note that which git-aliases
will not work, since all are sourced shell functions, not executable binaries.
For a fully manual install, execute the following lines to first clone repository into $HOME
, and moving file out of the directory & then load it:
git clone https://github.com/webcdn/git-aliases.git "$HOME"
cd "$HOME"
mv ./git-aliases/aliases.sh ./.git_aliases
source ./.git_aliases
Now, add these lines to your ~/.bashrc
, ~/.profile
, or ~/.zshrc
file to have it automatically sourced upon login:
(you may have to add to more than one of the above files)
[ -s "$HOME/.git_aliases" ] && source "$HOME/.git_aliases" # This loads git-aliases
To remove aliases
manually, execute the following:
rm "$HOME/.git_aliases"
Edit your profile-files ~/.bashrc
, ~/.profile
, or ~/.zshrc
(or other shell resource config) and remove the lines similar to :
[ -s "$HOME/.git_aliases" ] && source "$HOME/.git_aliases" # This loads git-aliases
Arguments are written in square braces [...]
are optional. [**]
denotes, you can always use core options/commands from core git
.
git-ver
git-ll
git-it "your commit message"
git-up ["your commit message" [origin [branch]]] [**]
git-amend ["your commit message"]
git-amend-now ["your commit message"]
git-push [origin [branch]] [**]
git-pushf [origin [branch]] [**]
git-pull [origin [branch]] [**]
git-pullf [origin [branch]]
git-clean [reflogs]
git-clear
git-sync [origin [branch]]
git-fixit
git-fixup [origin [branch]] [**]
git-rebase [**]
Prints the current version of the git-aliases
git-ver
# v1.0-beta
Long List of commit history, each in single row with proper color for better readability (latest to oldest order)
git-ll
# <comit-id> - <origin-branch> <commit-message> (<commit-time>) [<commit-author>]
add all files to staged list and commit it
git-it "your commit message"
Please ensure your commit message follows the conventional commits format:
type(scope): description
- type could be one of: build, chore, ci, docs, feat, fix, perf, refactor, revert, style
- scope is optional and can be anything specifying the place of the commit change
- description is a short description of the change
These conventions make it easier for others to understand the changes, streamline the development process, and help in generating changelogs or navigating through the history of the project.
- build: changes that affect the build system or external dependencies
- chore: regular code maintenance
- ci: changes made to CI configuration files and scripts
- docs: documentation related changes
- feat: a new feature added
- fix: a bug fix
- perf: changes that improves performance
- refactor: changes that neither fixes a bug nor adds a feature
- revert: if the commit reverts a previous commit, this is used with the hash of the commit being reverted
- style: changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
- test: changes that adds missing tests or corrects existing tests
Add all files to staged list and commit it. Finally, push up to the remote server. You may specify origin & branch at the end.
git-up "your commit message"
git-up "new featured changes" origin beta
Modifying your last commit. This will update uncommit changes to the last commit. If you are specifying the commit-message, then it will be updated too. Mostly used for correction purposes. In case of amendments, code must be pushed forcefully otherwise it will throw an error.
git-amend
git-amend "your commit message"
Modifying your last commit. This will update commit time, author who is working at the foremost. If you are specifying the commit-message, then it will be updated too. Mostly used for correction purposes. In case of amendments, code must be pushed forcefully otherwise it will throw an error.
git-amend-now
git-amend-now "your commit message"
Push all pending commits to remote cloud. If pushed with
git-pushf
, commits are forced to be pushed.
git-push
# with origin
git-push new_origin
# with origin & branch
git-push new_origin slave
# you may also add core git push options at the end
git-push new_origin staging
# NOTE: git-pushf options are same as in git-push
Pull all pending commits from remote cloud. This is launched with auto detection.
git-pull
# with origin
git-pull new_origin
# with origin & branch
git-pull new_origin slave
# you may also add core git pull options at the end
git-pull new_origin staging
Pull changes from remote cloud, and forcefully reset with your current branch.
git-pullf
# with origin
git-pullf new_origin
# with origin & branch
git-pullf new_origin staging
Clean garbage or unnecessary reflog objects from the
.git
directory. It works locally.
git-clean
Clear your working space. This will remove all staged & unstaged files.
git-clear
Sync from remote. This additionally clear all the staged files & then pull the code forcefully
git-sync
# with origin
git-sync new_origin
# with origin & branch
git-sync new_origin staging
Fixing previous commit. This will add a new commit with fixup tag as prefix to previous commit message.
# same purpose as git-amend but here this will create a new commit
git-fixit
Fixing previous commit & push it. This will add a fixup commit & push on remote origin.
# same purpose as git-amend but here this will create a new commit
git-fixup
# with origin
git-fixup origin
# with origin & branch
git-fixup new_origin staging
Automatically Rebase Commits. This will rebase you commits based on the prefix keywords added till the provided
HEAD
/HASH
.
# rebasing till hash
git-rebase 84c63b39
git-rebase 84c63b3910bb28b5f0549e235ac0f4f3a3c71a1b
# rebasing last 5 commits
git-rebase HEAD~5
# rebasing from root
git-rebase --root
Automatically Merge Branch. This ensures that the merge is always done with a separate merge commit.
# merging new branches
git-merge feature-branch
git-merge another-feature-branch
Automatically Merge Branch. This helps to merge the feature branch to main branch without changing the branch, you can continue working in the same feature branch.
# merging feature branch to
git-merge-to main-branch
git-merge-to another-main-branch
Remove Commit. If reset with
git-resetf
, codes are forced to be updated.
# removes last commit from history only
git-reset
# removes commit upto this hash,
# but the code remains unchanged
git-reset 84c63b39
git-reset 84c63b3910bb28b5f0549e235ac0f4f3a3c71a1b
# removes last commit & codes
git-resetf
# removes upto commit hash & codes
git-resetf 84c63b39
git-resetf 84c63b3910bb28b5f0549e235ac0f4f3a3c71a1b
$ git-it
# c1b8fd544 - oauth added (1 minutes ago) [webcdn]
$ git-fixit
# 7056e6ef2 - fixup! oauth added (1 minutes ago) [webcdn]
# c1b8fd544 - oauth added (2 minutes ago) [webcdn]
$ git-fixit
# d4bc5b9fa - fixup! fixup! oauth added (1 minutes ago) [webcdn]
# 7056e6ef2 - fixup! oauth added (2 minutes ago) [webcdn]
# c1b8fd544 - oauth added (2 minutes ago) [webcdn]
$ git-rebase HEAD~3
# e33621e8e - oauth added (a few seconds ago) [webcdn]
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.