mainbranch, but in teams we almost never want to code on
mainis reserved for tested and approved code running in production. Once a developer completes their new feature in their feature branch, they can merge their branch back to
mainto "release" the feature to their teammates and users.
main, it can be deleted.
git checkoutallows us to switch or "checkout" branches, and the
-bflag creates a new branch and checks it out.
mainwhen we created the branch. New commits on our branch will be independent from new commits on any other branch.
git checkoutwithout the
-bflag to checkout an existing branch.
kebab-caseby convention if there is more than one word.
mainso others can admire our work. Here is how we can do this.
main, we should checkout
git mergefollowed by the source branch, e.g.
main. Often when developing a larger feature, we will want to merge
maininto our feature branch periodically to verify whether our changes still work with the latest code on
main. This is to pre-empt situations where someone may have committed changes to
mainthat are incompatible with the features on our branch.
git statusto see which files have conflicts.
git statusoutput. These have merge conflicts.
spellingbranch ends with the following.
>characters above. VSCode highlights merge conflicts in our files, providing convenient buttons to choose 1 change or another.
addthem to staging and
committhem. This will trigger Git to create a merge commit with an auto-generated commit message.
git merge --abort.
water-poem.txt. Commit this file to the repo.
water-poem.txthas reverted to the version on
mainand merge the water poem edits from the water poem branch.
water-poem.txtcontains the changes from the water poem branch.