GitAlias / gitalias
- понедельник, 20 июня 2016 г. в 03:12:57
91 stars today
Git alias commands for faster easier version control
This project provides many git alias commands that you can use as you like.
For the full list, see the file gitalias.txt.
Examples:
s
for status
.optimize
to prune and repack using recommended settings.graphviz
to show logs and charts using third-party tools.topic-start
to create a new topic branch using master.See the file gitalias.txt
.
Copy/paste anything you like into your own .gitconfig
file.
Shortcuts:
a = add
b = branch
c = commit
…
Shortcuts with options:
ap = add --patch
be = branch --edit-description
ci = commit --interactive
…
Get everything new:
get = !git pull --rebase && git submodule update --init --recursive
Rebase interactive on unpushed commits:
rbi = !git rebase --interactive @{u}
Show changes for a daily standup meeting:
log-standup = !git log --since yesterday --pretty=short --author `git config user.email`
Find text in any commit ever:
grep-all = !"git rev-list --all | xargs git grep '$1'"
Publish the current branch by pushing and tracking:
publish = "!git push -u origin $(git branch-name)"
Unpublish the current branch by deleting the remote branch:
unpublish = "!git push origin :$(git branch-name)"
Prune stale items:
pruner = !git prune --expire=now; git reflog expire --expire-unreachable=now --rewrite --all
Repack the way Linus recommends:
repacker = !git repack -a -d -f --depth=300 --window=300 --window-memory=1g
Alias configuration for our topic branches, like a simple git flow for feature stories, or hotfix patches, etc.
Create a new topic branch:
topic-start = '!branch=$1; git checkout master; git pull; git checkout -b "$branch" master'
Update the topic branch:
topic-pull = '!branch=$(git branch-name); git checkout master; git pull; git checkout "$branch"; git rebase master'
Share the topic branch:
topic-push = '!branch=$(git branch-name); git push -u origin "$branch"'
If your team uses a different topic flow, you may want to skip including these aliases, or you may want to edit these aliases to match your team's topic flow.
You can customize any of the file items by editing the file as you like.
You can also customize any of the file items by adding your own item later in your own gitconfig file.
For example you can include our aliases then customize "git l" with your own definition:
[include]
path = ~/.gitconfig.d/alias.txt
[alias]
l = log --graph --oneline
To use better pretty formatting:
[format]
pretty = "%H %ci %ce %ae %d %s"
If you like terse status messages:
[alias]
s = status -sb
If you like log summaries:
[alias]
l = log --graph --oneline
We are creating this alias list because we type these commands many times daily, and we want the commands to be fast and also accurate.
We often work on teams, across many companies and organizations, and using multiple shells. We want to count on a set of aliases. For shorter commands, such as s
for status
, fast speed is nice. For longer commands, such as repacker
, accurate settings are important.
More ideas:
alias g=git
.oh-my-zsh
, then you may like the git pluginnode
, then try git-aliasFor more git config ideas, and for credit for many of the aliases here, please see these excelent resources: