A simple git workflow

Git workflow for new branch

  1. Create an issue on GitHub
  2. Update local main branch: git checkout main && git pull
  3. Create a branch with the format issue_number-description (e.g., git checkout -b 42-new-branch
  4. Make your changes and stage them (e.g., git add newFile.js )
  5. Check that the appropriate files are staged: git status
  6. Commit the changes: git commit
  7. (Optional) If, at this stage, your branch not up-to-date with the latest main, rebase using git rebase origin/main OR merge using git merge origin/main
  8. Push to remote branch with same name: git push -u origin 42-new-branch
  9. Create a Pull Request with, for example, Closes #42 in the body to link the issue
  10. Merge the branch on GitHub and delete the branch after
  11. Assuming you are still on your branch, update your local repo with git pull origin main:main
  12. Switch to main: git checkout main
  13. Delete your branch: git branch -d 42-new-branch

Updating your branch while it is still in progress

  1. Commit or stash your changes: git commit OR git stash
  2. Switch to main: git checkout main
  3. Update main: git pull
  4. Return to your branch: git checkout 42-my-branch
  5. Rebase or merge: git rebase main OR git merge main
  6. (Optional) If you stashed your changes, reapply them: git stash apply

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Join the #NoServerNovember Challenge

[Update] May 16 (Mon) Update Notes

Complete guide to use GraphQL in Laravel

Top Mistakes That Developers Are Making While Developing Flutter App

CS371 Spring 2022: Hrithik Ramganesh

How The Tables Have Turned

Establish a connection between Ansible server and two-node using SSH & ssh-keygen

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Calvin Ho

Calvin Ho

More from Medium

How to write inline JavaScript code in a Power Automate Flow

Introduction to GIT 👨‍💻👩‍💻

GitHub Process

Most basic Git commads that every programmer must know