Posts mit dem Label git werden angezeigt. Alle Posts anzeigen
Posts mit dem Label git werden angezeigt. Alle Posts anzeigen

Dienstag, 4. Februar 2014

Must Have Git Aliases

Git Shortcut

This is first thing you should do. Aliasing git as `g` will save you a lot of typing. After this symlink creation you can access git with only typing `g` in the command line.
$ sudo ln -s `which git` /usr/bin/g
I'm using git now for some years and over the time I came up with a long list of git aliases. Git is great and can give you a great coding experience with it's customizable shortcuts.

Your .gitconfig file is located in your home dir. All examples can be added to the [alias] section in this file.
$ nano ~/.gitconfig

Basic Aliases

  co = checkout
  cp = cherry-pick
  p  = pull
  squash = merge --squash
  st = status
  df = diff
  b = branch

Advanced Usage

Revert a file

  rv = checkout --

Merging

  ours = checkout --ours --
  theirs = checkout --theirs --

Stashing

  sl = stash list
  sa = stash apply
  ss = stash save

Danger! Cleanup working dir

This alias will reset all modified files!
cleanup = !git reset --hard && git clean -f 

List all aliases

alias = config --get-regexp 'alias.*'

Log One Line

logol = log --pretty=format:"%h\\ %s\\ [%cn]"

Search in files

search = "grep -Iin"

Vagrant

vup = !vagrant up
vsu = !vagrant suspend
vss = !vagrant ssh
vde = !vagrant destroy
vpr = !vagrant provision

Donnerstag, 30. Januar 2014

Git Jira commit Message


It's easy to commit a jira task without entering the complete task title in the command line. Initially I wrote a simple script for my gender detection project that uses the jira api to fetch the required fields from the Jira server to generate a meaningful commit message but this script can simply be used for any other project.

Link to the script: https://github.com/markus-perl/git-jira-commit-message/blob/master/git-jira-commit-message

Edit the script and enter your credentials:
 #!/usr/bin/php
    <?php
    
    $username = 'Jira username';
    $password = 'jira password';
    $api = 'http://my.jira.url/rest/api/2/';

Now add the following line to the alias section in your .gitconfig file which is located in your home dir:

[alias]
  c = !sh -c 'git-jira-commit-message "$0"'


To commit a task just enter the task id. The script the title of the task to the commit message:

$ git c PR-1201