====== Git-Tricks ======
===== Commit-Datum ändern (z.B. Import alter Code) =====
GIT_AUTHOR_DATE='Wed Dec 19 15:14:05 2029 -0800' git commit -m 'future!'
GIT_AUTHOR_DATE='2029-12-19 15:14:05 -0800' git commit -m 'future!'
GIT_AUTHOR_DATE="`date -Iseconds -u -r 'oldest file'`" git commit -m 'past!'
===== Unterverzeichnisse rausziehen =====
To rewrite the repository to look as if foodir/ had been its project root, and discard all other history:
git filter-branch --subdirectory-filter ABC --prune-empty -- --all
Remove directory from history:
git filter-branch --index-filter "git rm -q -r -f --cached --ignore-unmatch ABC" --prune-empty -- --all
Mit Subtree:
## create branch that tracks only MyLibraryRepo/*
git subtree split -P MyLibraryRepo -b export
## make new repo
cd ~/Projects
mkdir LibraryRepo
cd LibraryRepo
git init
# copy over commits...
git fetch ../bigrepo export
# ... and define master as them
git checkout -b master FETCH_HEAD
===== Changelog =====
git log --format="- %B" --reverse Previous-Release..HEAD
===== Branch verschieben =====
Beispiel: Feature-Branch vergessen, 2 commits sind schon auf master (aber nicht gepusht)
git update-ref refs/heads/master `git rev-parse master^2`
===== Revision in git-svn Import suchen =====
Repo ist ein git-svn Mirror, wir suchen den Commit in dem eine bestimmte SVN-Revision gelandet ist
git log | grep -B8 -A1 @34724
===== Dateidatum auf das Datum des letzten Commits setzen =====
(git ls-files) | % { (Get-Item $_).LastWriteTime=(git log --pretty=format:%cd -n 1 --date=iso $_) }
===== Development branch in einen neuen für PR interaktiv rekonstruieren =====
git-pickbranch my-new-pr master develop
#!/bin/bash
set -e
FB=$1
START=$2
TAIL=$3
# switch to feature branch, make it point to last of set
git checkout -B $FB
git reset --hard $TAIL
# rebuild between first and last as feature branch, branching on start
git rebase -i --onto $START $START $FB