Coder Social home page Coder Social logo

gitalias's Introduction

Git Alias

This project provides many git alias commands that you can use as you like.

Contents:

To see the complete code, view these files:

We use Git version control every day. We like to make it faster, easier, and better.

We create Git alias items to help us, such as:

  • Shortcuts such as s for status.
  • Improvements such as optimize to prune and repack using recommended settings.
  • Visualizations such as graphviz to show logs and charts using third-party tools.
  • Topic branch flows such as topic-start to create a new topic branch using master.
  • For links to many more ideas and git alias files, see the end of this file.

This is simply a text file. Copy what you like.

  1. See the file gitalias.txt.

  2. 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

Plurals:

branches = branch -a
stashes = stash list

Log:

log-graph = log --graph --all  --decorate --oneline
log-standup = !git log --since yesterday --author $(git config user.email) --pretty=short

Workflow:

get = !git pull --rebase && git submodule update --init --recursive
put = !git commit --all --message="$1" && git push

Topics:

topic-start  = "!f(){ b=$1; git checkout master; git fetch; git rebase; git checkout -b "$b" master; };f"
topic-finish = "!f(){ b=$(git branch-name); git checkout master; git branch -d "$b"; git push origin ":$b"; };f"

Grep:

grep-group =  grep --break --heading --line-number
grep-all = !"git rev-list --all | xargs git grep '$1'"

Name:

branch-name = rev-parse --abbrev-ref HEAD
upstream-name = !git for-each-ref --format='%(upstream:short)' $(git symbolic-ref -q HEAD)

Combine:

ours   = !"f() { git checkout --ours $@ && git add $@; }; f"
theirs = !"f() { git checkout --theirs $@ && git add $@; }; f"

Publish:

publish = "!git push -u origin $(git branch-name)"
unpublish = "!git push origin :$(git branch-name)"

Optimize:

pruner = !git prune --expire=now; git reflog expire --expire-unreachable=now --rewrite --all
repacker = !git repack -a -d -f --depth=300 --window=300 --window-memory=1g

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.

Alias

To include our aliases then customize "git l" with your own definition:

[include]
   path = ~/.gitconfig.d/gitalias.txt
   path = ~/.gitconfig.d/gitalias-for-topic-branches.txt

[alias]
   l = log --graph --oneline

Format

To use better pretty formatting:

[format]
  pretty = "%H %ci %ce %ae %d %s"

Status

To use terse status messages:

[alias]
  s = status -sb

Log

To use log summaries:

[alias]
  l = log --graph --oneline

Purpose

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 for git improvements:

  • If you want to alias the git command, then use your shell, such as alias g=git.
  • If you want history views, see git-recall
  • If you use oh-my-zsh, then you may like the git plugin
  • If you use vim then see Fugitive
  • If you use emacs then see Magit
  • If you use git shell scripting then see SCM Breeze
  • If you use node then see git-alias

For more git config ideas, and for credit for many of the aliases here, please see these excelent resources:

We welcome people contributing, such as creating pull requests, or creating issue reports, or tweeting ideas to us.

  • We're aiming to have new kinds of pull requests open for a week to encourage comments.

We want this project to be a good starting point for teams.

  • We're aiming for consensus and practicality.

  • We want ease of use, ease of composability, and ease of understanding.

  • We use the Git documentation guidelines for our coding format.

  • We like meaningful comments and practical examples to help novices.

We prefer this git commit message format:

  • Subject
    • Start with an imperative verb, such as "Add", "Remove", "Fix", "Upgrade", etc.
    • Capitalize the line, for example "Add" not "add".
    • Limit the line to 50 characters.
    • End the line without a period.
    • Use a blank line after the subject to separate the subject from the body.
  • Body
    • Wrap the body at 72 characters.
    • Use the body to explain what and why vs. how.
    • For commits with more than one author, add "Author: Alice [email protected]".
    • For commits that refer to a URL, add "URL: https://example.com".
    • For commits that refer to a tracker, use the complete URL, not just a number or code.
  • For more info see How to write a git commit message.

Thanks to all the contributors, including all the creators of the projects mentioned above.

Thanks to these people for extra help:

gitalias's People

Contributors

gautamkrishnar avatar gliptak avatar joelparkerhenderson avatar mchl avatar nickpalmer avatar pachoyan avatar phdru avatar sectsect avatar volendi avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.