Skip to content

Instantly share code, notes, and snippets.

View tomaszprasolek's full-sized avatar
😊

Tomasz Prasołek tomaszprasolek

😊
View GitHub Profile
@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"
[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 / 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
{
"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 | "/?")
@tomaszprasolek
tomaszprasolek / git_script.ahk
Last active April 27, 2022 07:09
My Git AutoHotKey script.
#SingleInstance force
#IfWinActive ahk_class CASCADIA_HOSTING_WINDOW_CLASS
::grc::git rebase --continue
::gmt::git mergetool
::gpf::git push --force-with-lease
::gch::git checkout
::gri::git rebase -i HEAD~
::gc::git commit
::gca::git commit --amend
::gcan::git commit --amend --no-edit
while :; do
output=$(git reflog)
clear
echo "$output"
sleep 1
done
@tomaszprasolek
tomaszprasolek / Change commiter and author date
Last active May 31, 2019 13:52
Change commiter and author date
git filter-branch --env-filter \
'if [ $GIT_COMMIT = 50421880a94e18f9344b43574eecbbab8e941c89 ]
then
export GIT_AUTHOR_DATE="Fri Nov 2 12:00:00 2018 +0000"
export GIT_COMMITTER_DATE="Fri Nov 2 12:00:00 2018 +0000"
fi'