Files
avaaz/docs/git.md
2025-11-24 00:30:36 +01:00

2.2 KiB

Git

  • GitHub Flow branching strategy is used.
  • Direct push to main branch is prohibited.
  • Only merges to the main branch via Pull Requests from feature/... or bugfix/... branches are allowed.
  • Tags are created for releases on the main branch.

Pull Request

  1. Ensure your main branch is protected, so that direct push is disabled.

  2. Update the local main branch.

    git checkout main
    git pull origin main
    
  3. Create a new branch, feature/new-branch, with a descriptive name and switch to it.

    git checkout -b feature/new-branch
    
  4. Add any changes.

    git add .
    
  5. Commit the changes with a message.

    git commit -m "new branch: create all boiler plate files"
    
  6. Push the new branch, feature/new-branch, to the remote Gitea repository.

    git push origin feature/new-branch
    
  7. Create a new Pull Request from feature/new-branch to the main branch.

  8. Review and Merge the new branch into the main branch.

  9. Switch back to the main branch.

    git checkout main
    
  10. Pull the latest changes that include the merged PR.

    git pull origin main
    
  11. Delete the local feature/new-branch branch.

    git branch -d feature/new-branch
    
  12. Delete the remote branch after merging if Gitea did not delete it.

    git push origin --delete feature/new-branch
    
  13. Create a new branch for upcoming work, for example feature/dev.

    git checkout -b feature/dev
    

Troubleshooting

Accidentally created a commit on local main branch instead of a feature branch

  1. Create a new branch pointing to the extra commit.

    git branch feature/new-branch
    
  2. Reset the local main branch to match the remote origin/main.

    git reset --hard origin/main
    
  3. Switch over to the new feature branch

    git checkout feature/new-branch
    
  4. Push the new branch.

    git push origin feature/new-branch
    
  5. Create a Pull Request.