Frequently used series of commands in Git
- Create and switch to a new branch (here: featurebranch)
git checkout -b featurebranch
- Examine your branches
git branch -vv
- Stage and commit your changes
git add myfile
git commit -m "My commit message"
- Push the new branch to GitHub
git push origin featurebranch
- Start tracking the remote branch
git branch -u origin/featurebranch
-
Create a pull request on GitHub
-
Continue committing on the branch and pushing while discussing development with collaborators on GitHub
- Switch to receiving branch (here main)
git checkout main
- Merge feature branch (here: featurebranch)
git merge featurebranch
-
(Eventually manage merge conflict)
-
Delete local feature branch
git branch -d featurebranch
- Push changes to main
git push
- Delete remote branch
git push origin --delete featurebranch