Add Jira Issue Number on the commit message

According to this snippet:

#!/bin/sh
#
# git prepare-commit-msg hook for automatically prepending an issue key
# from the start of the current branch name to commit messages.

# check if commit is merge commit or a commit ammend
if [ $2 = "merge" ] || [ $2 = "commit" ]; then
    exit
fi
ISSUE_KEY=`git branch | grep -o "\* \(.*/\)*[A-Z]\{2,\}-[0-9]\+" | grep -o "[A-Z]\{2,\}-[0-9]\+"`
if [ $? -ne 0 ]; then
    # no issue key in branch, use the default message
    exit
fi
# issue key matched from branch prefix, prepend to commit message
TEMP=`mktemp /tmp/commitmsg-XXXXX`
(echo "$ISSUE_KEY: $(cat  $1)") > $TEMP
cat $TEMP > $1
  1. Make sure the folder(s) ~/.git_template/hooks exists
  2. Drop the file above in there and make sure it’s named prepare-commit-msg
  3. make ~/.git_template/hooks/prepare-commit-msg executable. (chmod +x)
  4. make sure your ~/.gitconfig contains
[init]
templatedir = ~/.git_template

Now anytime you checkout a repo OR use git init in a directory, the prepare-commit-msg will be copied into your project’s .git/hooks folder.

Note: You can safely run git init within pre-existing git projects to get the file copied over

Credits to Jonathan Doklovic

Delete all local untracked branches from GIT

This is a very handy command for cleaning up all the branches you already merged and closed on origin GIT server. Feel free to use and comment if you have any issues.

git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -d

Link of the Gist to share and comment.

Also, some branches are not fully merged and will need to be deleted manually. Then you use:

git branch -D branch_name

Hope that it helps you!

Error on Windows Server 2016 Language Settings

The following error appears when you try to put a new language on windows server:

Windows cannot access the specified device, path or file. You may not have the appropriate permissions to access the item.

Steps to solve this problem:

  1. Win + R and type ‘secpol.msc’ for open the Local Security Policy console.
  2. In the Security Settings tree, open Local Policies > Security Options.
  3. Find the policy: User Account Control: Admin Approval Mode for the Built-in Administrator account and enable it.
  4. Log out – log in, voilá!