{"id":21360626,"url":"https://github.com/zachwhaley/git-workflow","last_synced_at":"2026-01-02T14:50:16.319Z","repository":{"id":244305522,"uuid":"814850917","full_name":"zachwhaley/git-workflow","owner":"zachwhaley","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-13T21:18:31.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-22T19:11:36.122Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zachwhaley.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-13T20:56:55.000Z","updated_at":"2024-06-13T21:18:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"4e5e1cd3-223c-4df6-ab33-1bdbde34aba5","html_url":"https://github.com/zachwhaley/git-workflow","commit_stats":null,"previous_names":["zachwhaley/git-workflow"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachwhaley%2Fgit-workflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachwhaley%2Fgit-workflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachwhaley%2Fgit-workflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zachwhaley%2Fgit-workflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zachwhaley","download_url":"https://codeload.github.com/zachwhaley/git-workflow/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243835951,"owners_count":20355611,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-22T05:35:32.999Z","updated_at":"2026-01-02T14:50:16.272Z","avatar_url":"https://github.com/zachwhaley.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Code Review Workflow\n\n## Setup Your Personal `.gitignore`\n\nEveryone is allowed and encouraged to setup their development environment with the tools they prefer. Some tools and environments, however, generate files specific to their functioning, that aren't part of the repo being worked on. To prevent such files from accidentally being committed to repos, and rather than trying to account for every possible dev environment within individual repos' `.gitignore` files, developers should configure a [personal global `.gitignore`](https://stackoverflow.com/questions/7335420/global-git-ignore) that accounts for their specific choice of tools.\n\nBroadly, the separation between repo vs personal `.gitignore`s is:\n\n* **repo**: Anything generated as part of processes inherent to the repo that will appear across any/all environment/s, regardless of the choice of dev tools, e.g. build/test artifacts.\n* **personal**: Anything generated as a result of the developer's choice, that will not always appear across all environments, e.g.:\n\n   ```gitignore\n   .DS_store # unique to macOS\n   .idea\n   .vscode\n   .sublime-workspace\n   ```\n\n## Start Your Work\n\nBefore starting any work, create a new branch off of the `main` branch.\n\nIt is good practice to give the branch a name that is relevant to the work being done.\n\nE.g. `fix-cli-printing-bug`, `add-component-of-feature`, etc.\n\n1. Switch to the main branch\n\n   ```shell\n   git switch main\n   ```\n\n1. Update the main branch\n\n   ```shell\n   git pull\n   ```\n\n1. Create a new working branch\n\n   ```shell\n   git switch -c WORKING_BRANCH\n   ```\n\n## Save Your Work\n\nFeel free to commit and push changes as often as you'd like to save any progress you've made.\n\nAs a general rule, try to make your commits as small and logical as possible. Leaving a trail of your thoughts for reviewers to read is the goal.\n\n1. Add and commit changes\n\n   ```shell\n   git add FILES\n   git commit\n   ```\n\n1. Push changes to GitHub\n\n   ```shell\n   git push\n   ```\n\n## Review Your Code\n\n1. Commit and pushed any changes you want reviewed.\n\n   ```shell\n   git add FILES\n   git commit\n   git push\n   ```\n\n1. Go to your repository's GitHub page.\n1. [Create a Pull Request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request)\n1. Add reviewers (GitHub might make reviewer suggestions, add those as well).\n1. Wait for comments and requests.\n\n## Address Comments\n\nReviewers will undoubtedly have comments and/or make requests for your changes.\n\nFor each request, add a new commit to address that request, then push your new commits.\n\nEvery time you push, the Pull Request will be automatically updated and reviewers notified.\n\n\u003e [!TIP]\n\u003e You do not need to push each commit. Making several commits and pushing once is fine.\n\n## Merge Your Code\n\nOnce you have gotten enough approvals, use the *Squash and Merge* button to prepare your changes for merge.\n\nThe _Squash and Merge_ button will present you with a text box to write a merge title and message.\nCheck that the merge title and message match your PR title and message.\n\nGeneral rules for commit messages:\n\n* For bug fixes, explain why this change fixes the bug.\n* For feature work, explain how this part of the feature is supposed to work.\n\nIf you'd like to read more about writing good commit messages check out this [blog post](https://chris.beams.io/posts/git-commit/).\n\n## Start Over\n\nNow that you're finished, it's time to get back to work!\n\nTo start new work, follow the same steps as before:\n\n1. Switch back to the main branch\n\n   ```shell\n   git switch main\n   ```\n\n1. Pull the latest changes\n\n   ```shell\n   git pull\n   ```\n\n1. Create a new branch for your work\n\n   ```shell\n   git switch -c NEW_WORKING_BRANCH\n   ```\n\n\u003e [!NOTE]\n\u003e If you get a merge conflict or git tries to create a merge commit, see [below](#i-have-merge-conflicts)\n \nNote, you do not need to do anything to your old branches, but if you do want to cleanup old Pull Request branches, checkout this [Stack Overflow answer](https://stackoverflow.com/a/6127884).\n\n## Wait, But What If?\n\n### Git won't let me pull main\n\nIf you are having trouble running `git pull` on the main branch, it may be that you accidentally made a commit on that branch before creating your working branch.\n\nTo fix this, create a \"temporary\" branch on your current main branch to make sure no commits are \"lost\".\n\n```shell\ngit switch main\ngit branch USERNAME/save-main\ngit switch USERNAME/save-main \n```\n\nThen re-checkout the main branch by deleting it and recreating it with `git switch`\n\n```shell\ngit branch -D main\ngit fetch\ngit switch main\n```\n\nYou can now safely delete your temporary branch\n\n```shell\ngit branch -D USERNAME/save-main\n```\n\n### My branch and the main branch have diverged\n\nAs long as there are no merge conflicts (which GitHub will warn you about), there is nothing you need to do.\n\nThe _Squash and Merge_ button will handle the divergence like magic.\n\n### I have merge conflicts!\n\nUse Git's merge command to `merge` the main branch into your working branch, resolve all conflicts, and push.\n\n```shell\ngit switch main\ngit pull\n\ngit switch WORKING_BRANCH\ngit merge main\n```\n\nResolve merge conflicts\n\n```shell\ngit commit\ngit push\n```\n\n### My branch is REALLY out of date\n\nSame as above, use Git's `merge` command to update your working branch.\n\n```shell\ngit switch main\ngit pull\n\ngit switch WORKING_BRANCH\ngit merge main\n\ngit push \n```\n\n### My new work depends on my open Pull Request\n\nIn this case, create a branch off of your Pull Request branch and start working from that.\n\n```shell\ngit switch PR_BRANCH\ngit pull\n\ngit switch -c NEW_WORKING_BRANCH\n```\n\nFYI, you can use a Draft Pull Request for work that is not yet ready.\n\n### My new work depends on someone else's open Pull Request\n\nThis is identical to the solution above, except you'll need to use that user's Pull Request branch before creating your new branch.\n\n```shell\ngit fetch\ngit switch COWORKERS_PR_BRANCH\ngit pull\n\ngit switch -c NEW_WORKING_BRANCH\n```\n\nMake sure to keep your branch up-to-date with changes from that user's Pull Request by periodically merging their branch into yours.\n\n```shell\ngit pull origin COWORKERS_PR_BRANCH\n```\n\n### I'm halfway done, but now I'm stuck waiting for someone else's fix\n\nThis is identical to the last step of the solution above. You just pull the other user's Pull Request into an existing branch instead of creating a new one.\n\n```shell\ngit pull origin COWORKERS_PR_BRANCH\n```\n\n### Someone else has pushed changes to my Pull Request\n\nSometimes it makes sense for a reviewer to push changes to your Pull Request. This is fine, but you will need to pull those changes locally before you will be allowed to push any of your changes.\n\nWith your working branch checked out, use the `pull` command with the remote and branch parameters to pull changes from your Pull Request branch.\n\n```shell\ngit switch PR_BRANCH\ngit pull origin PR_BRANCH\n```\n\n## Useful Stuff\n\n* [Git documentation](https://git-scm.com/doc)\n* [Git basics](https://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository)\n* [Git in Bash](https://git-scm.com/book/en/v2/Appendix-A%3A-Git-in-Other-Environments-Git-in-Bash)\n* [GitHub desktop app](https://desktop.github.com/)\n* [GitHub command line tool](https://cli.github.com/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzachwhaley%2Fgit-workflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzachwhaley%2Fgit-workflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzachwhaley%2Fgit-workflow/lists"}