A quick vocab review | |
---|---|
What is a remote? | |
Where do branches live? local vs. origin vs. your local copy of origin | |
What's the difference between " | |
What are integration branches? |
The Seven Golden Rules of git
hygiene
- Thou shalt make a new branch off latest
master
for every ticket. - Thou shalt include a ticket ID in every branch name and every commit.
- Thou shalt always PR.
- Thou shalt always review thy Files Changed.
- Thou shalt never merge thy own Pull Requests.
- Thou shalt delete thy merged branches.
- Thy branches shall be short-lived.
...
1. Thou shalt make a new branch for every ticket.
Make very sure your local copy of master
is up-to-date with origin before branching!
1 ticket = 1 branch: Don't mix work from different issues.
...
7. Thy branches shall be short-lived.
The longer your branch sits around, the more likely you are to run into more merge conflicts and be working with out-of-date code. Don't let your branches sit around for more than a few days, a week at most. This. Get them to a good stopping point and submit your pull-request. If you want to commit code from a branch that is more than a week old, make a new branch off latest master
and cherry-pick your old work into the new branch.
"Can't I just merge latest
master
into my own branch?" you ask. Why, yes, you may, but (a) it creates merge commit bubbles and (b) navigating the possible resultant merge conflicts requires great care, skill, and time; 'tis best not to let your branches get old in the first place.
The need for this rule, of course, depends on the velocity of the project and with how many team members you work, but you are likely to run into more merge conflicts and be working with out-of-date code the longer your branch sits aroundit is a good and important general practice.
Bonus. Thou shalt ask for help.
...
And you care about line lengths, grammar, punctuation, and other inane details, then Read Chris Beam's How to Write a Git Commit Message and follow The seven rules of a great commit message.Also for the retentive folks: Always delete (non-integration) branches from GitHub after PR merge.