Skip to content

Instantly share code, notes, and snippets.

@dahoba
Forked from leesmith/simple-git-workflow.md
Created August 27, 2021 05:10
Show Gist options
  • Save dahoba/b1e22a91764042a350102f9d16c4b3eb to your computer and use it in GitHub Desktop.
Save dahoba/b1e22a91764042a350102f9d16c4b3eb to your computer and use it in GitHub Desktop.
Simple Git Workflow For Continuous Delivery

Simple Git Workflow For Continuous Delivery

Workflow guidelines:

  • master branch is always production-ready, deployable, 100% green test suite
  • New development is done on feature branches, with frequent rebasing onto master
  • Clean commit history by preferring to rebase instead of merge (git pull is configured to automatically rebase)

rebase workflow

Workflow

  1. Pull the latest from origin/master:

    git pull origin master
    
  2. Create your feature branch

    git checkout -b concise-feature-branch-name
    
  3. Begin work on the new feature

  4. Keep your feature branch updated with master by rebasing onto master:

    git fetch origin master
    git rebase origin/master
    

    or

    git checkout master
    git pull
    git checkout concise-feature-branch-name
    git rebase master
    

    Resolve any conflicts that occur during rebase.

  5. Push your branch remotely and create a pull request when ready for peer review:

    git push -u origin concise-feature-branch-name
    

    Depending on peer review, keep pushing changes to the remote as needed.

  6. Interactively rebase your feature branch onto master once the feature is approved and ready for production:

    git rebase -i origin/master
    
  7. Merge into master:

    git checkout master
    git pull origin master
    # The --no-ff is optional here...see the notes below
    git merge --no-ff concise-feature-branch-name
    git push origin master
    # This is also a good time to create a release tag
    git tag 1.0.10
    git push 1.0.10
    
  8. Remove all branches that have been merged into master:

    git branch -d concise-feature-branch-name
    git push origin :concise-feature-branch-name
    

Notes

  • Git config for rebasing by default:

    git config --global branch.autosetuprebase always
    git config --global pull.rebase true
    
  • Merging into master in step 7 with the --no-ff option will create a merge commit even if the merge could be a fast-forward. Having this merge commit is helpful in that it retains the commits that went into the feature branch. (If you don't care to keep this series of commits on a feature branch or the feature branch was a single commit, you can omit the --no-ff in the merge command and let it fast-foward.) Single-level merge bubbles like this are ok. Here's what we don't want:

merge-bubbles

Credits

https://www.atlassian.com/it/git/articles/simple-git-workflow-is-simple

https://gist.github.com/jbenet/ee6c9ac48068889b0912

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