git

git flow feature start TAG-##

git add <files>
git commit <changes>

git flow feature publish

# Code Review #
# IF Ok:
    git flow feature finish
    # Ticket Done #

# ELSE: Repeat until ok:
    git commit <further changes>
    # Code Review #
    # 
Workflow:
 - Git Flow
 - Git Messages —> TicketID <Short Description> ggf. Description, falls notwendig - nicht zwingend erforderlich
# Helpers:
# Undo
git flow feature delete your-feature-branch

# Manual Undo
git checkout develop
git branch -d feature/your-feature-branch
# Branches Diverged for some reason? —> rebase
git pull --rebase

show remote origins

git remote -v

> origin    git@repo.foo.com:bar/repo.git (fetch)
> origin    git@repo.foo.com:bar/repo.git (push)

change last commit message

git commit --amend
# change message

# push fast-forward
git push -ff

set upstream for branch

Sometimes when using git flow feature start a remote tracking branch is not created. We then have to create the branch first:

git branch --set-upstream-to=origin/feature/ID-XXX feature/ID-XXX

creating a local backup for experiments

git tag BACKUP
< do some dangerous stuff (w/o pushing of course)>
git reset --hard BACKUP

rebase and undo rebase

git checkout feature/ID-001 # switch to feature branch
git stash # stash all working changes
git rebase develop # rebase our branch on develop
git stash apply # apply our changes

git stash # stash changes before undo
git reset --hard ORIG_HEAD # undo the rebase

better git log

git reflog # gives a nice overview

git log # default
git log -g # uses reflog info instead of log

git ignore file / folder

# Install Git Extras:
brew install git-extras

git rm --cached <file>
git rm -r --cached <folder>

git ignore <folder/file>

git feature sync with develop

git checkout feature/foo
git pull --all
git rebase develop

git grep within history

git grep <regexp> $(git rev-list --all)