Skip to content

Instantly share code, notes, and snippets.

@thiagosouza
Last active October 10, 2016 21:31
Show Gist options
  • Save thiagosouza/391f651dcf7544219741ce5822e7d566 to your computer and use it in GitHub Desktop.
Save thiagosouza/391f651dcf7544219741ce5822e7d566 to your computer and use it in GitHub Desktop.
#git #git-flow
#http://danielkummer.github.io/git-flow-cheatsheet/
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
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
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/
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

Initialize

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

Connect to the remote repository

gitflow git
N/A git remote add origin [email protected]:MYACCOUNT/MYREPO

Features

Create a feature branch

gitflow git
git flow feature start MYFEATURE git checkout -b feature/MYFEATURE develop

Share a feature branch

gitflow git
git flow feature publish MYFEATURE git checkout feature/MYFEATURE
git push origin feature/MYFEATURE

Get latest for a feature branch

gitflow git
git flow feature pull origin MYFEATURE git checkout feature/MYFEATURE
git pull --rebase origin feature/MYFEATURE

Finalize a feature branch

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

Push the merged feature branch

gitflow git
N/A git push origin develop
git push origin :feature/MYFEATURE (if pushed)

Releases

Create a release branch

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

Share a release branch

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

Get latest for a release branch

gitflow git
N/A git checkout release/1.2.0
git pull --rebase origin release/1.2.0

Finalize a release branch

gitflow git
git flow release finish 1.2.0 git 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

gitflow git
N/A git 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

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

Finalize a hotfix branch

gitflow git
git flow hotfix finish 1.2.1 git 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

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

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment