Git Dev Index

Git

First configure your global identity, configuration file resides on ~/.gitconfig ;

       $ git config --global user.name "User Name"
       $ git config --global user.email user@devbox
    

Assumptions of this document;

Team WorkFlow

This work flow is based on Vicent Driessen, development model, it defines rules how branches are forked, merged and tagged. By having well defined set of branches, the project structure is used as a communication tool, allowing to work simultaneously on different stages of the development.

       $ git clone devbox:atom
       $ git remote -v
    

Main Branches;

master
Current official stable release history.
release
Next release, new features not allowed.
develop
Integration branch for features.

Add-on Branches;

feature
New features, improvement proposal, tests, etc...
hotfix
Hotfix is branched of master and should only contain isolated bugfixes.

Feature

Create a branch and checkout;

    $ git checkout -b featurex develop
    

Push new branch to server

    $ git push -u origin featurex
    

Rename a branch;

        $ git branch -m featurex feature-x
    

Rename remote branch;

        $ git push origin :featurex feature-x
        $ git push origin -u feature-x
    

Merge branch feature into develop;

       $ git checkout develop
       Switched to branch 'develop'
       $ git merge --no-ff feature-x
       Updating ea1b82a..05e9557
       (Summary of changes)
       $ git push origin develop
    

Delete Local;

       $ git branch -D feature-x
    

Delete Remote

       $ git push origin :feature-x
    

Release

       $ git checkout -b release-1.2 develop
       Switched to a new branch "release-1.2"
       $ ./bump-version.sh 1.2
       Files modified successfully, version bumped to 1.2.
       $ git commit -a -m "Bumped version number to 1.2"
       [release-1.2 74d9424] Bumped version number to 1.2
       1 files changed, 1 insertions(+), 1 deletions(-)
    

Only documentation or bugfixes are allowed in this branch. When release is ready for production merge and push to master;

       $ git checkout master
       Switched to branch 'master'
       $ git merge --no-ff release-1.2
       Merge made by recursive.
       (Summary of changes)
       $ git tag -a 1.2
    

Update branch develop with bugfixes from last release, conflict will happen in next step

       $ git checkout develop
       Switched to branch 'develop'
       $ git merge --no-ff release-1.2
       Merge made by recursive.
       (Summary of changes)
    

Hotfix

This branch should never exist, ;)

       $ git checkout -b hotfix-1.2.1 master
       $ ./bump-version.sh 1.2.1
       Files modified successfully, version bumped to 1.2.1
       $ git commit -a -m "Bumped version number to 1.2"
    
       $ git commit -m "Commit severe fixes"
    
       $ git checkout master
       Switched to branch 'master'
       $ git merge --no-ff release-1.2.1
       Merge made by recursive.
       (Summary of changes)
       $ git tag -a 1.2.1
    

Conflict will happen in next step

       $ git checkout develop
       Switched to branch 'develop'
       $ git merge --no-ff release-1.2.1
       Merge made by recursive.
       (Summary of changes)
    
       $ git -D hotfix-1.2.1
    

Tags

    $ git tag -m "this commit is tagged" -a "v1.8"
    $ git push --follow-tags
    

Delete local and remote tag;

    $ git tag -d v1.8
    $ git push origin :refs/tags/v1.8
    

Local Workflow

Mark all deleted to commit;

    $ git ls-files --deleted -z | xargs -0 git rm
    

Last commit that affected current path

    $ git rev-list -n 1 HEAD -- .
    $ git show f000 path/to/file
    $ git diff --name-status f000 path/to/file
    

Undo a file to specific commit

    $ git checkout f000^ -- path/to/file
    
Dev Index

This is part of the SysDoc Manual. Copyright (C) 2016 Silvino Silva. See the file Gnu Free Documentation License for copying conditions.