thiago-s
7/25/2016 - 8:20 PM

#git #git-flow

#git #git-flow

Initialize

gitflowgit
git flow initgit init
git commit --allow-empty -m "Initial commit"
git checkout -b develop master

Connect to the remote repository

gitflowgit
N/Agit remote add origin git@github.com:MYACCOUNT/MYREPO

Features

Create a feature branch

gitflowgit
git flow feature start MYFEATUREgit checkout -b feature/MYFEATURE develop

Share a feature branch

gitflowgit
git flow feature publish MYFEATUREgit checkout feature/MYFEATURE
git push origin feature/MYFEATURE

Get latest for a feature branch

gitflowgit
git flow feature pull origin MYFEATUREgit checkout feature/MYFEATURE
git pull --rebase origin feature/MYFEATURE

Finalize a feature branch

gitflowgit
git flow feature finish MYFEATUREgit checkout develop
git merge --no-ff feature/MYFEATURE
git branch -d feature/MYFEATURE

Push the merged feature branch

gitflowgit
N/Agit push origin develop
git push origin :feature/MYFEATURE (if pushed)

Releases

Create a release branch

gitflowgit
git flow release start 1.2.0git checkout -b release/1.2.0 develop

Share a release branch

gitflowgit
git flow release publish 1.2.0git checkout release/1.2.0
git push origin release/1.2.0

Get latest for a release branch

gitflowgit
N/Agit checkout release/1.2.0
git pull --rebase origin release/1.2.0

Finalize a release branch

gitflowgit
git flow release finish 1.2.0git checkout master
git merge --no-ff release/1.2.0
git tag -a 1.2.0
git checkout develop
git merge --no-ff release/1.2.0
git branch -d release/1.2.0

Push the merged feature branch

gitflowgit
N/Agit push origin master
git push origin develop
git push origin --tags
git push origin :release/1.2.0 (if pushed)

Hotfixes

Create a hotfix branch

gitflowgit
git flow hotfix start 1.2.1 [commit]git checkout -b hotfix/1.2.1 [commit]

Finalize a hotfix branch

gitflowgit
git flow hotfix finish 1.2.1git checkout master
git merge --no-ff hotfix/1.2.1
git tag -a 1.2.1
git checkout develop
git merge --no-ff hotfix/1.2.1
git branch -d hotfix/1.2.1

Push the merged hotfix branch

gitflowgit
N/Agit push origin master
git push origin develop
git push origin --tags
git push origin :hotfix/1.2.1 (if pushed)

References

RELEASE_NAME='1.2/3'

#release/[MAJOR].[MINOR]/[REVISION]
#Exemplo:
#release/1.2/3

# use the data as release may be ok
#RELEASE_NAME='2016/07/'

#git flow release list

git flow release start $RELEASE_NAME

git flow release publish $RELEASE_NAME

git flow release finish $RELEASE_NAME
#or
git flow release finish -F -p $RELEASE_NAME
#git checkout master
#git fetch origin master #Latest objects have been fetched from 'origin'
#git merge –no-ff $RELEASE_NAME #Release branch has been merged into 'master'
#git tag -a $RELEASE_NAME #The release was tagged '$RELEASE_NAME'
#git push origin master
#git checkout develop
#git fetch origin develop 
#git merge –no-ff $RELEASE_NAME #Release branch has been back-merged into 'develop'
#git push origin develop #'develop', 'master' and tags have been pushed to 'origin'
#git branch –d $RELEASE_NAME #Release branch 'release/$RELEASE_NAME' has been deleted

FEATURE_NAME='bootstrap_project'

# git flow feature start <name> [<base>]

git flow feature start $FEATURE_NAME
#git branch feature/ReadmeAdd
#git checkout feature/ReadmeAdd

touch README
git add README
git commit -m "Added readme file with some text"

git flow feature publish $FEATURE_NAME
#git push origin feature/$FEATURE_NAME
#git config branch.feature/$FEATURE_NAME.remote origin
#git config branch.feature/$FEATURE_NAME.merge refs/heads/feature/$FEATURE_NAME
#git checkout feature/$FEATURE_NAME

#git flow feature pull [alias] [featureName]
git flow feature pull origin $FEATURE_NAME
#First time feature pull:
#git fetch origin feature/$FEATURE_NAME
#git branch --no-track feature/$FEATURE_NAME FETCH_HEAD
#git checkout feature/$FEATURE_NAME
#Subsequent feature pull
#git pull origin feature/$FEATURE_NAME

# before git flow finish
# git checkout develop # you should probably be here already
git pull origin develop

#git flow feature finish [featureName]
git flow feature finish $FEATURE_NAME
#git checkout develop
#git merge –no-ff feature/$FEATURE_NAME
#git branch -d feature/$FEATURE_NAME

# after git flow finish
git push origin :feature/$FEATURE_NAME #if you want to remove remote branch

# https://yakiloo.com/getting-started-git-flow/
GIT_REPO='/var/www/tpassos/git/demo-repo'

cd $GIT_REPO
git flow init
#No branches exist yet. Base branches must be created now.
#Branch name for production releases: [master]
#Branch name for "next release" development: [develop]

#How to name your supporting branch prefixes?
#Feature branches? [feature/]
#Release branches? [release/]
#Hotfix branches? [hotfix/]
#Support branches? [support/]
#Version tag prefix? []

#for existing repositories may be good to check the existent branches
#git branch -a | grep feature
#git branch -a | grep release
#git branch -a | grep hotfix
#git branch -a | grep support
#git branch -a | grep tags


git push origin develop

git pull origin develop
GIT_REPO_REMOTE='/var/www/tpassos/git/demo-repo.git'
GIT_REPO='/var/www/tpassos/git/demo-repo'

# cerate a remote git repository
mkdir -p $GIT_REPO_REMOTE
cd $GIT_REPO_REMOTE
git init --bare --shared

# create a local copy of the remote's repo
mkdir -p $GIT_REPO
cd $GIT_REPO
git init
git remote add origin $GIT_REPO_REMOTE
git remote -v

# OR

# git clone the remote repo
git clone $GIT_REPO_REMOTE $GIT_REPO
#http://danielkummer.github.io/git-flow-cheatsheet/