Skip to content

Latest commit

 

History

History
153 lines (113 loc) · 2.79 KB

File metadata and controls

153 lines (113 loc) · 2.79 KB

Git in 15 minutes

Workflow

check "A successful Git branching model" link

The central repo holds two main branches with an infinite lifetime:

  • master
  • develop

Creating a feature branch

git checkout -b myfeature develop

Incorporating a finished feature on develop

git checkout develop
git merge --no-ff myfeature
git branch -d myfeature
git push origin develop

Creating a release branch

git checkout -b release-1.2 develop
./bump-version.sh 1.2
git commit -a -m "Bumped version number to 1.2"

Finishing a release branch

git checkout master
git merge --no-ff release-1.2
git tag -a 1.2
git checkout develop
git merge --no-ff release-1.2
git branch -d release-1.2

For hotfix branches check the mentioned link.

Common commands in my workflow

Nice log

git log --graph

Nicer log

git log --graph --full-history --all --color --pretty=format:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s"

similar but shotrer

git log --format=oneline
git log --graph --all --simplify-by-decoration

Another nicer log

git log --oneline --pretty='%C(red)%h%CresetI%C(yellow)%d%Creset%s%C(green)(%cr)%Creset'

Create aliases (e.g.for nice log)

git config alias.lg "log --oneline --pretty='%C(red)%h%CresetI%C(yellow)%d%Creset%s%C(green)(%cr)%Creset'"
git lg

2 diffs

git diff
git diff ..staged

Add and commit (without newly created)

git commit -am  "<commit message>"

Reset

Just move HEAD

git reset --soft

Move HEAD + adjust working directory

git reset --hard

HEAD + index without working directory

git reset --mixed

2 steps back

git reset --hard^^
git reset --hard~2

Not so common commands

git log master..myfeature
git rebase master

For debugging

git bisect start head~5
git bisect run

Low level commands

git show-ref
git cat-file -p [SHA part]
git ls-tree -r [SHA part]

Great links