-
Clone the repository
git clone [email protected]:your-brother-username/repo-name.git cd repo-name
-
Create and switch to a feature branch
git checkout -b your-feature-name
-
Make code changes...
-
Stage and commit changes
git add . git commit -m "Describe your feature"
-
Push the feature branch to origin and set upstream
git push -u origin your-feature-name
-
Open GitHub and create a pull request from
your-feature-name
intomain
-
You can continue making changes, committing, and pushing to the same branch
git add . git commit -m "Follow-up changes" git push
These commits will be automatically added to the open pull request.
-
Once the feature is complete, merge the pull request using the GitHub interface
It’s usually better to use squash merge or rebase merge rather than a merge commit, to keep the main branch history clean -
Switch back to the
main
branch locallygit checkout main
-
Pull the latest changes from origin
git pull origin main
-
Delete the local feature branch
git branch -d your-feature-name
If you used a squash merge or rebase merge in GitHub:
git branch -D your-feature-name
-
Delete the remote feature branch
git push origin --delete your-feature-name
Or delete it directly in the GitHub interface after merging the pull request
Last active
June 27, 2025 15:07
-
-
Save adeluccar/8674e4aa345c099bdeed685b7d9e1fa7 to your computer and use it in GitHub Desktop.
Step-by-step guide for working with feature branches in a GitHub repo: clone, branch, commit, push, open a pull request, merge (preferably squash or rebase), and clean up local and remote branches.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Excellent guide!
Understood everything. Thank you for explaining it.