Git: putting your new feature out into the world.
A git workflow to put a local feature out in the wild, then tidy up after yourself.

So you’ve added a new feature to your project. You were responsible and didn’t do this in the main branch. Congrats on being responsible, have some brownie points.
Now how the heck to you get everything moved across and delete your new-feature branch?
1. Check that your local main is up to date.
Be in the main branch and pull any changes to the remote main branch.
git checkout main 
git pull origin mainThis might require you to resolve some merge conflicts, but these should be pretty straightforward if you are following a branch-and-merge workflow.
2. Check that you remote new-feature is up to date.
We might mess things up while merging. Let’s make sure that if that happens we can get back to this good position with our new feature.
git checkout new-feature
git statusIf needed: add, commit and push.
3. Merge any changes to main into your local new-feature branch
Next, we will make sure we have any changes to main moved across to our local new-feature branch.
git merge mainThis might again require resolving some merge conflicts. Keep calm and take tea breaks are required.
4. Commit and push to remote.
Now that we have our local new-feature branch compatible with the remote main branch, lets push that to the remote.
git add <YOUR_FILES_TO_COMMIT>
git commit -m "merge changes to main in preparation for PR"
git push5. Open a pull request on Github
Wait for someone to review approve your new feature (or wait a few hours/days and do it yourself for a solo project).
6. Delete the local branch
git checkout main
git branch --delete new-feature7. Delete the remote branch
git push origin --delete new-featureOn older versions of git (< 1.7.0) you might need to use the alternative syntax below. This is effectively pushing nothing to the new-feature branch of origin.
git push origin :new-featureBam! You did it! Your new-feature is out there in the wild, making the world a marginally better place.