Skip to content

Instantly share code, notes, and snippets.

View tomaszprasolek's full-sized avatar
😊

Tomasz Prasołek tomaszprasolek

😊
View GitHub Profile
@tomaszprasolek
tomaszprasolek / filter-branch-prepend-and-append
Created July 11, 2018 10:07 — forked from openjck/filter-branch-prepend-and-append
Using sed and filter-branch to prepend and append to Git commit messages without newlines
# Prepending text to the five most recent commit messages:
git filter-branch --msg-filter 'sed "s/\(.*\)/[prepended text] \1/g"' HEAD~5..HEAD
# Appending text to the five most recent commit messages:
git filter-branch --msg-filter 'sed "s/\(.*\)/\1 [appended text]/g"' HEAD~5..HEAD
@tomaszprasolek
tomaszprasolek / prepare-commit-msg
Last active July 19, 2018 06:30
Shell script for git hook to add work item ID to commit message. I work with VSTS and work items IDs is numbers. To associate commit with work item I must add at the end of commit message char # and ID e.g. #123.
#!/bin/sh
BRANCH_NAME=$(git symbolic-ref --short HEAD)
STORY_NUMBER=$(echo $BRANCH_NAME | sed -n 's/.*-\([0-9]\)/\1/p') # Get story number from branch name - "my_feature_branch-123"
COMMIT_MSG=`cat $1`
if [ x != x${STORY_NUMBER} ]; then # Checf if STORY_NUMBER is NOT empty
if [ x = x${2} ]; then # Check if commit message is empty
sed -i.back "1s/^/#$STORY_NUMBER/" "$1"
{
"font_size": 14,
"hot_exit": false,
"ignored_packages":
[
"Vintage"
],
"close_windows_when_empty": true
}
C:\Program Files\Git\bin\sh.exe --login -i -new_console:d:"<path>"
@tomaszprasolek
tomaszprasolek / git show-branch output
Last active October 25, 2018 11:20
Code is used in my blog.
! [master] Test commit 01 - master
* [feature] Test commit 03
--
+ [master] Test commit 01 - master
* [feature] Test commit 03
* [feature^] Test commit 02
* [feature~2] Test commit 01
+* [master^] Update ref tests
#!/bin/bash
USAGE="USAGE: git append TEXT_TO_APPEND NUMBER_OF_COMMITS\nExample: git append \"#3301\" 5"
show_usage () {
echo -e "\n$USAGE"
}
case $1 in
help | -h | "/?")
while :; do
output=$(git reflog)
clear
echo "$output"
sleep 1
done
@tomaszprasolek
tomaszprasolek / createEmptyCommits.sh
Created January 9, 2019 16:21
Create 5 empty commits with passed message. For test purposes only.
#!/bin/bash
for i in {1..5}
do
git commit -m "$1 $i" --allow-empty
done
[user]
name = "TO FILL"
email = "TO FILL"
[core]
autocrlf = true
excludesfile = C:\\Users\\tpraso\\Documents\\gitignore_global.txt
#editor = "'C:\\Program Files\\Sublime Text 3\\sublime_text.exe' -w -n"
editor = "'C:\\Program Files\\Sublime Text 3\\subl.exe' -w -n"
[alias]
lg = log --color --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cd) %C(yellow)<%an>%Creset' --date=human
@tomaszprasolek
tomaszprasolek / git-feature
Last active March 27, 2019 13:24
Script create local branch and after that set upstream branch
#!/bin/bash
if [ x = x${1} ]; then
echo ">>> Enter branch name"
exit 1
fi
if [[ $1 == feature* ]]
then
BRANCH_NAME=$1