Skip to content

Instantly share code, notes, and snippets.

@mRoca
Last active November 6, 2020 17:10

Revisions

  1. mRoca revised this gist Jan 23, 2019. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions git_flow.md
    Original file line number Diff line number Diff line change
    @@ -104,10 +104,13 @@ You can add some git aliases and configure some options by editing your `.gitcon
    [alias]
    lg = log --abbrev-commit --decorate --date=relative --color --graph --pretty=tformat:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%an %ar)%Creset'
    lgall = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
    c = commit
    co = checkout
    st = status
    f = fetch
    br = branch
    a = add
    r = rebase
    rere = rebase -i HEAD~2
    rerere = rebase -i HEAD~3
    [rerere]
  2. mRoca revised this gist Apr 18, 2016. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions git_flow.md
    Original file line number Diff line number Diff line change
    @@ -123,6 +123,7 @@ git rere # git rebase -i HEAD~2
    git rerere # git rebase -i HEAD~3
    git lg # git log
    git lgall # git log --all
    git a, git st, git br, ...
    ```

    # Workflow - Howto
  3. mRoca revised this gist Apr 18, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git_flow.md
    Original file line number Diff line number Diff line change
    @@ -3,10 +3,10 @@
    | Item | Name |
    | --------------------- | ----------------------------- |
    | Release branch | release/v2.0.1 |
    | Feature branch | feature/my_feature_name |
    | Feature branch | feature/2234_my_feature_name |
    | Hotfix branch | hotfix/my_hotfix_name |
    | Commit | Add my news |
    | Commit resolving issue| #1234 Add my news |
    | Tag | v2.0.1 |
    | Hotfix Tag | v2.0.1.1 |
    | Work in progress PR | [WIP] #1234 My pull request |
  4. mRoca revised this gist Apr 18, 2016. 1 changed file with 12 additions and 2 deletions.
    14 changes: 12 additions & 2 deletions git_flow.md
    Original file line number Diff line number Diff line change
    @@ -35,7 +35,7 @@ git fetch --all --verbose --prune
    git fetch -vap

    # List branches
    git branch -v
    git branch -av

    # List commits for the current branch (see below "git lg" for a better command line)
    git log
    @@ -58,7 +58,14 @@ git checkout -b my_new_branch
    # Create a new branch from another branch
    git checkout -b my_new_branch the_old_branch

    # Work commit after changes
    # Add added or updated files to the next comit
    git add .
    git add my/file

    # Track and commit all updated files
    git commit -a

    # Commit after changes
    # If the commit refers to an existing issue, put the issue #ID at the beggining of the message :
    git commit -am "#1234 Add the git flow documentation"

    @@ -78,6 +85,9 @@ git branch -d my_branch

    # Delete a remote branch
    git push origin :my_branch

    # ...
    git help
    ```

    # gitconfig
  5. mRoca revised this gist Apr 18, 2016. No changes.
  6. mRoca revised this gist Apr 18, 2016. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions git_flow.md
    Original file line number Diff line number Diff line change
    @@ -52,7 +52,7 @@ git pull --rebase origin my_branch
    # Choose the right branch
    # Look the issue target version, or ask to your lead dev

    # Create a new branch
    # Create a new branch from the current branch
    git checkout -b my_new_branch

    # Create a new branch from another branch
    @@ -132,8 +132,7 @@ git checkout v2.0.1
    ## I want to work on an issue / feature

    ```bash
    git checkout release/v2.0.1
    git checkout -b feature/2234_my_feature_name
    git checkout -b feature/2234_my_feature_name release/v2.0.1
    ```

    ## I want to get all new commit from a release branch in my feature branch
  7. mRoca revised this gist Mar 10, 2016. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions git_flow.md
    Original file line number Diff line number Diff line change
    @@ -237,3 +237,7 @@ git branch -d hotfix/fix_some_things
    git co release/v2.0.2
    git merge release/v2.0.1
    ```

    # Refs

    http://csarrazi-slides.github.io/git-for-teams
  8. mRoca revised this gist Mar 8, 2016. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions git_flow.md
    Original file line number Diff line number Diff line change
    @@ -96,6 +96,8 @@ You can add some git aliases and configure some options by editing your `.gitcon
    lgall = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
    co = checkout
    st = status
    br = branch
    a = add
    rere = rebase -i HEAD~2
    rerere = rebase -i HEAD~3
    [rerere]
  9. mRoca revised this gist Nov 25, 2015. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions git_flow.md
    Original file line number Diff line number Diff line change
    @@ -80,6 +80,8 @@ git branch -d my_branch
    git push origin :my_branch
    ```

    # gitconfig

    You can add some git aliases and configure some options by editing your `.gitconfig` file :

    [user]
  10. mRoca revised this gist Nov 25, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git_flow.md
    Original file line number Diff line number Diff line change
    @@ -90,7 +90,7 @@ You can add some git aliases and configure some options by editing your `.gitcon
    [push]
    default = simple
    [alias]
    lg = log --abbrev-commit --decorate --date=relative --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)'
    lg = log --abbrev-commit --decorate --date=relative --color --graph --pretty=tformat:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%an %ar)%Creset'
    lgall = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
    co = checkout
    st = status
  11. mRoca revised this gist Nov 13, 2015. 1 changed file with 14 additions and 2 deletions.
    16 changes: 14 additions & 2 deletions git_flow.md
    Original file line number Diff line number Diff line change
    @@ -5,14 +5,26 @@
    | Release branch | release/v2.0.1 |
    | Feature branch | feature/2234_my_feature_name |
    | Hotfix branch | hotfix/my_hotfix_name |
    | Commit | #1234 Add my news |
    | Commit | Add my news |
    | Commit resolving issue| #1234 Add my news |
    | Tag | v2.0.1 |
    | Hotfix Tag | v2.0.1.1 |
    | Work in progress PR | [WIP] #1234 My pull request |
    | Ready for review PR | [RFR] #1234 My pull request |

    # Basics
    ## Commit message

    Every good commit should be able to complete the following sentence :
    `When applied, this commit will: {{ YOUR COMMIT MESSAGE}}`

    ```
    For example:
    – When applied this commit will Update README file
    – When applied this commit will Add validation for GET /user/:id API call
    – When applied this commit will Revert commit 12345
    ```

    # Basics

    ```bash
    # Clone the repo from the remote
  12. mRoca revised this gist Nov 4, 2015. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions git_flow.md
    Original file line number Diff line number Diff line change
    @@ -81,6 +81,7 @@ You can add some git aliases and configure some options by editing your `.gitcon
    lg = log --abbrev-commit --decorate --date=relative --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)'
    lgall = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
    co = checkout
    st = status
    rere = rebase -i HEAD~2
    rerere = rebase -i HEAD~3
    [rerere]
  13. mRoca revised this gist Jun 25, 2015. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions git_flow.md
    Original file line number Diff line number Diff line change
    @@ -20,6 +20,7 @@ git clone <remote_repo>

    # Refresh all branches from remote
    git fetch --all --verbose --prune
    git fetch -vap

    # List branches
    git branch -v
  14. mRoca revised this gist Jun 25, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions git_flow.md
    Original file line number Diff line number Diff line change
    @@ -24,10 +24,10 @@ git fetch --all --verbose --prune
    # List branches
    git branch -v

    # List commits for the current branch (see below "git lg" for a best command line)
    # List commits for the current branch (see below "git lg" for a better command line)
    git log

    # List commits for all branches (see below "git lgall" for a best command line)
    # List commits for all branches (see below "git lgall" for a better command line)
    git log --all --graph

    # Switch to a branch
  15. mRoca revised this gist Jun 25, 2015. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions git_flow.md
    Original file line number Diff line number Diff line change
    @@ -18,11 +18,11 @@
    # Clone the repo from the remote
    git clone <remote_repo>

    # Refresh branches from remote
    git fetch --all
    # Refresh all branches from remote
    git fetch --all --verbose --prune

    # List branches
    git branch
    git branch -v

    # List commits for the current branch (see below "git lg" for a best command line)
    git log
  16. mRoca revised this gist May 13, 2015. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion git_flow.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@

    # Naming convention

    | Item | Name |
    @@ -50,6 +49,10 @@ git checkout -b my_new_branch the_old_branch
    # If the commit refers to an existing issue, put the issue #ID at the beggining of the message :
    git commit -am "#1234 Add the git flow documentation"

    # Commit new changes in the last commit, or change the last commit message
    git commit --amend -a
    git commit --amend -am "The new commit message"

    # Send your branch to the remote
    git push origin my_branch

  17. mRoca revised this gist May 11, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git_flow.md
    Original file line number Diff line number Diff line change
    @@ -137,7 +137,7 @@ git push -f
    git cherry-pick 28f0f05
    ```

    ## I want to merge my feature with code review and PR :
    ## I want to merge my feature with code review and PR

    ```bash
    git checkout feature/2234_my_feature_name
  18. mRoca revised this gist May 11, 2015. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions git_flow.md
    Original file line number Diff line number Diff line change
    @@ -146,10 +146,12 @@ git push -f origin feature/2234_my_feature_name
    ```

    **Merge with Gitlab**

    Go to Gitlab, then create a Merge Request from your feature branch, to the target release branch. Put a label at the beginning of the name : [WIP] or [RFR].
    Wait for the *+1* comment from another team member, then use the `Accept merge request` button, checking `Delete the merged branch` checkbox

    **Merge with Github**

    Go to Github, then create a Pull Request from your feature branch in your forked project, to the target release branch in the parent project. Put a label at the beginning of the name : [WIP] or [RFR].
    Wait for the *+1* comment from another team member, then use the `Merge PR` button, then delete the merged branch

  19. mRoca revised this gist May 11, 2015. 1 changed file with 17 additions and 20 deletions.
    37 changes: 17 additions & 20 deletions git_flow.md
    Original file line number Diff line number Diff line change
    @@ -57,14 +57,6 @@ git push origin my_branch
    git rebase -i HEAD~X
    # You editor will open itself, then replace the words "pick" by "squash" on each line to squash, except the first one, save and quit.

    # Merge with Gitlab
    # Go to Gitlab, then create a Merge Request from your feature branch, to the target release branch. Put a label at the beginning of the name : [WIP] or [RFR].
    # Wait for the +1 comment from another team member, then use the `Accept merge request` button, checking `Delete the merged branch` checkbox

    # Merge with Github
    # Go to Github, then create a Pull Request from your feature branch in your forked project, to the target release branch in the parent project. Put a label at the beginning of the name : [WIP] or [RFR].
    # Wait for the +1 comment from another team member, then use the `Merge PR` button, then delete the merged branch

    # Delete a local branch
    git branch -d my_branch

    @@ -145,9 +137,25 @@ git push -f
    git cherry-pick 28f0f05
    ```

    ## I want to merge my feature with code review and PR :

    ```bash
    git checkout feature/2234_my_feature_name
    git rebase release/v2.0.1
    git push -f origin feature/2234_my_feature_name
    ```

    **Merge with Gitlab**
    Go to Gitlab, then create a Merge Request from your feature branch, to the target release branch. Put a label at the beginning of the name : [WIP] or [RFR].
    Wait for the *+1* comment from another team member, then use the `Accept merge request` button, checking `Delete the merged branch` checkbox

    **Merge with Github**
    Go to Github, then create a Pull Request from your feature branch in your forked project, to the target release branch in the parent project. Put a label at the beginning of the name : [WIP] or [RFR].
    Wait for the *+1* comment from another team member, then use the `Merge PR` button, then delete the merged branch

    ## I want to merge my feature in a release branch

    Without code review (and PR / MR) :
    Caution : this method is without code review (and PR / MR), normally not used.

    ```bash
    git checkout release/v2.0.1 # Switch to the release branch
    @@ -158,17 +166,6 @@ git branch -d feature/2234_my_feature_name # Delete the local feature branch
    git push origin :feature/2234_my_feature_name # Delete the remote feature branch
    ```

    With code review and PR :

    ```bash
    git checkout feature/2234_my_feature_name
    git rebase release/v2.0.1
    git push -f origin feature/2234_my_feature_name
    ```

    Then go to Github / Gitlab, and create the PR. Put a label at the beginning of the name : [WIP] or [RFR].
    Wait for the **+1** from another team member, then use the `Merge PR` button, checking `Delete the merged branch` checkbox

    ## I want to create a new release branch

    ```bash
  20. mRoca revised this gist May 11, 2015. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions git_flow.md
    Original file line number Diff line number Diff line change
    @@ -43,6 +43,9 @@ git pull --rebase origin my_branch
    # Create a new branch
    git checkout -b my_new_branch

    # Create a new branch from another branch
    git checkout -b my_new_branch the_old_branch

    # Work commit after changes
    # If the commit refers to an existing issue, put the issue #ID at the beggining of the message :
    git commit -am "#1234 Add the git flow documentation"
  21. mRoca revised this gist May 7, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions git_flow.md
    Original file line number Diff line number Diff line change
    @@ -9,8 +9,8 @@
    | Commit | #1234 Add my news |
    | Tag | v2.0.1 |
    | Hotfix Tag | v2.0.1.1 |
    | Work in progresse PR | [WIP] #1234 My pull request |
    | Ready for Review PR | [RFR] #1234 My pull request |
    | Work in progress PR | [WIP] #1234 My pull request |
    | Ready for review PR | [RFR] #1234 My pull request |

    # Basics

  22. mRoca revised this gist May 7, 2015. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions git_flow.md
    Original file line number Diff line number Diff line change
    @@ -55,11 +55,11 @@ git rebase -i HEAD~X
    # You editor will open itself, then replace the words "pick" by "squash" on each line to squash, except the first one, save and quit.

    # Merge with Gitlab
    # Go to Gitlab, then create a Merge Request from your feature branch, to the target release branch. Put a label a the name begin : [WIP] or [RFR].
    # Go to Gitlab, then create a Merge Request from your feature branch, to the target release branch. Put a label at the beginning of the name : [WIP] or [RFR].
    # Wait for the +1 comment from another team member, then use the `Accept merge request` button, checking `Delete the merged branch` checkbox

    # Merge with Github
    # Go to Github, then create a Pull Request from your feature branch in your forked project, to the target release branch in the parent project. Put a label a the name begin : [WIP] or [RFR].
    # Go to Github, then create a Pull Request from your feature branch in your forked project, to the target release branch in the parent project. Put a label at the beginning of the name : [WIP] or [RFR].
    # Wait for the +1 comment from another team member, then use the `Merge PR` button, then delete the merged branch

    # Delete a local branch
    @@ -163,7 +163,7 @@ git rebase release/v2.0.1
    git push -f origin feature/2234_my_feature_name
    ```

    Then go to Github / Gitlab, and create the PR.
    Then go to Github / Gitlab, and create the PR. Put a label at the beginning of the name : [WIP] or [RFR].
    Wait for the **+1** from another team member, then use the `Merge PR` button, checking `Delete the merged branch` checkbox

    ## I want to create a new release branch
  23. mRoca revised this gist May 7, 2015. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions git_flow.md
    Original file line number Diff line number Diff line change
    @@ -6,9 +6,11 @@
    | Release branch | release/v2.0.1 |
    | Feature branch | feature/2234_my_feature_name |
    | Hotfix branch | hotfix/my_hotfix_name |
    | Commit | #2234 Add my news |
    | Commit | #1234 Add my news |
    | Tag | v2.0.1 |
    | Hotfix Tag | v2.0.1.1 |
    | Work in progresse PR | [WIP] #1234 My pull request |
    | Ready for Review PR | [RFR] #1234 My pull request |

    # Basics

    @@ -53,11 +55,11 @@ git rebase -i HEAD~X
    # You editor will open itself, then replace the words "pick" by "squash" on each line to squash, except the first one, save and quit.

    # Merge with Gitlab
    # Go to Gitlab, then create a Merge Request from your feature branch, to the target release branch
    # Go to Gitlab, then create a Merge Request from your feature branch, to the target release branch. Put a label a the name begin : [WIP] or [RFR].
    # Wait for the +1 comment from another team member, then use the `Accept merge request` button, checking `Delete the merged branch` checkbox

    # Merge with Github
    # Go to Github, then create a Pull Request from your feature branch in your forked project, to the target release branch in the parent project
    # Go to Github, then create a Pull Request from your feature branch in your forked project, to the target release branch in the parent project. Put a label a the name begin : [WIP] or [RFR].
    # Wait for the +1 comment from another team member, then use the `Merge PR` button, then delete the merged branch

    # Delete a local branch
  24. mRoca revised this gist May 7, 2015. 1 changed file with 19 additions and 4 deletions.
    23 changes: 19 additions & 4 deletions git_flow.md
    Original file line number Diff line number Diff line change
    @@ -14,8 +14,11 @@


    ```bash
    # Clone the repo
    git clone <repo_ssh_path>
    # Clone the repo from the remote
    git clone <remote_repo>

    # Refresh branches from remote
    git fetch --all

    # List branches
    git branch
    @@ -29,6 +32,9 @@ git log --all --graph
    # Switch to a branch
    git checkout my_branch

    # Get current branch changes from remote
    git pull --rebase origin my_branch

    # Choose the right branch
    # Look the issue target version, or ask to your lead dev

    @@ -39,17 +45,26 @@ git checkout -b my_new_branch
    # If the commit refers to an existing issue, put the issue #ID at the beggining of the message :
    git commit -am "#1234 Add the git flow documentation"

    # Send your branch to the remote
    git push origin my_branch

    # Squash X commits into a single one
    git rebase -i HEAD~X
    # You editor will open itself, then replace the words "pick" by "squash" on each line to squash, except the first one, save and quit.

    # Merge with Gitlab
    # Go to Gitlab, then create a Merge Request from your feature branch, to the target release branch
    # Wait for the **+1** from another team member, then use the `Accept merge request` button, checking `Delete the merged branch` checkbox
    # Wait for the +1 comment from another team member, then use the `Accept merge request` button, checking `Delete the merged branch` checkbox

    # Merge with Github
    # Go to Github, then create a Pull Request from your feature branch in your forked project, to the target release branch in the parent project
    # Wait for the **+1** from another team member, then use the `Merge PR` button, then delete the merged branch
    # Wait for the +1 comment from another team member, then use the `Merge PR` button, then delete the merged branch

    # Delete a local branch
    git branch -d my_branch

    # Delete a remote branch
    git push origin :my_branch
    ```

    You can add some git aliases and configure some options by editing your `.gitconfig` file :
  25. mRoca revised this gist May 7, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions git_flow.md
    Original file line number Diff line number Diff line change
    @@ -20,10 +20,10 @@ git clone <repo_ssh_path>
    # List branches
    git branch

    # List commits for the current branch
    # List commits for the current branch (see below "git lg" for a best command line)
    git log

    # List commits for all branches (see below for the complete command line)
    # List commits for all branches (see below "git lgall" for a best command line)
    git log --all --graph

    # Switch to a branch
  26. mRoca revised this gist May 7, 2015. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion git_flow.md
    Original file line number Diff line number Diff line change
    @@ -20,6 +20,12 @@ git clone <repo_ssh_path>
    # List branches
    git branch

    # List commits for the current branch
    git log

    # List commits for all branches (see below for the complete command line)
    git log --all --graph

    # Switch to a branch
    git checkout my_branch

    @@ -35,7 +41,7 @@ git commit -am "#1234 Add the git flow documentation"

    # Squash X commits into a single one
    git rebase -i HEAD~X
    # Replace "pick" by "s" on each line to squash, except the first one, the save and quit.
    # You editor will open itself, then replace the words "pick" by "squash" on each line to squash, except the first one, save and quit.

    # Merge with Gitlab
    # Go to Gitlab, then create a Merge Request from your feature branch, to the target release branch
  27. mRoca revised this gist May 7, 2015. 1 changed file with 2 additions and 4 deletions.
    6 changes: 2 additions & 4 deletions git_flow.md
    Original file line number Diff line number Diff line change
    @@ -33,7 +33,7 @@ git checkout -b my_new_branch
    # If the commit refers to an existing issue, put the issue #ID at the beggining of the message :
    git commit -am "#1234 Add the git flow documentation"

    # Squash X commits in a single one
    # Squash X commits into a single one
    git rebase -i HEAD~X
    # Replace "pick" by "s" on each line to squash, except the first one, the save and quit.

    @@ -53,8 +53,6 @@ You can add some git aliases and configure some options by editing your `.gitcon
    email = yourName@gmail.com
    [core]
    excludesfile = /home/yourName/.gitignore
    filemode = false
    editor = vim
    [push]
    default = simple
    [alias]
    @@ -75,7 +73,7 @@ git co master # git checkout master
    git rere # git rebase -i HEAD~2
    git rerere # git rebase -i HEAD~3
    git lg # git log
    git lgall # git log --graph
    git lgall # git log --all
    ```

    # Workflow - Howto
  28. mRoca revised this gist May 7, 2015. 1 changed file with 70 additions and 2 deletions.
    72 changes: 70 additions & 2 deletions git_flow.md
    Original file line number Diff line number Diff line change
    @@ -6,11 +6,79 @@
    | Release branch | release/v2.0.1 |
    | Feature branch | feature/2234_my_feature_name |
    | Hotfix branch | hotfix/my_hotfix_name |
    | Commit | #2234 add my news |
    | Commit | #2234 Add my news |
    | Tag | v2.0.1 |
    | Hotfix Tag | v2.0.1.1 |

    # HOWTO
    # Basics


    ```bash
    # Clone the repo
    git clone <repo_ssh_path>

    # List branches
    git branch

    # Switch to a branch
    git checkout my_branch

    # Choose the right branch
    # Look the issue target version, or ask to your lead dev

    # Create a new branch
    git checkout -b my_new_branch

    # Work commit after changes
    # If the commit refers to an existing issue, put the issue #ID at the beggining of the message :
    git commit -am "#1234 Add the git flow documentation"

    # Squash X commits in a single one
    git rebase -i HEAD~X
    # Replace "pick" by "s" on each line to squash, except the first one, the save and quit.

    # Merge with Gitlab
    # Go to Gitlab, then create a Merge Request from your feature branch, to the target release branch
    # Wait for the **+1** from another team member, then use the `Accept merge request` button, checking `Delete the merged branch` checkbox

    # Merge with Github
    # Go to Github, then create a Pull Request from your feature branch in your forked project, to the target release branch in the parent project
    # Wait for the **+1** from another team member, then use the `Merge PR` button, then delete the merged branch
    ```

    You can add some git aliases and configure some options by editing your `.gitconfig` file :

    [user]
    name = yourName
    email = yourName@gmail.com
    [core]
    excludesfile = /home/yourName/.gitignore
    filemode = false
    editor = vim
    [push]
    default = simple
    [alias]
    lg = log --abbrev-commit --decorate --date=relative --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)'
    lgall = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
    co = checkout
    rere = rebase -i HEAD~2
    rerere = rebase -i HEAD~3
    [rerere]
    enabled = true

    With this `.gitconfig` file, you can add a `.gitignore` file in your home and add all your IDE hidden directories (.idea, .sublime, ...).

    Somes aliases are added with this file :

    ```bash
    git co master # git checkout master
    git rere # git rebase -i HEAD~2
    git rerere # git rebase -i HEAD~3
    git lg # git log
    git lgall # git log --graph
    ```

    # Workflow - Howto

    ## I want to switch to a release branch

  29. mRoca revised this gist May 7, 2015. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion git_flow.md
    Original file line number Diff line number Diff line change
    @@ -36,13 +36,15 @@ git checkout -b feature/2234_my_feature_name
    ```bash
    git checkout feature/2234_my_feature_name
    git rebase release/v2.0.1
    git push -f feature/2234_my_feature_name
    # Or git rebase release/v2.0.1 feature/2234_my_feature_name
    ```

    ## I want to merge my two last feature commits in a single commit to clean the history and make future merges easier

    ```bash
    git rebase -i HEAD~2
    git push -f
    ```

    ## I want to get only one commit from another branch in the current branch
    @@ -69,7 +71,7 @@ With code review and PR :
    ```bash
    git checkout feature/2234_my_feature_name
    git rebase release/v2.0.1
    git push origin feature/2234_my_feature_name
    git push -f origin feature/2234_my_feature_name
    ```

    Then go to Github / Gitlab, and create the PR.
  30. mRoca revised this gist May 7, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git_flow.md
    Original file line number Diff line number Diff line change
    @@ -72,7 +72,7 @@ git rebase release/v2.0.1
    git push origin feature/2234_my_feature_name
    ```

    Then go to Github / Gitlab, and create the PR / MR
    Then go to Github / Gitlab, and create the PR.
    Wait for the **+1** from another team member, then use the `Merge PR` button, checking `Delete the merged branch` checkbox

    ## I want to create a new release branch