Source Control Best Practices

Status
Not open for further replies.

ProgrammingWolf

Smack-Fu Master, in training
53
Hi All,

I've decided to embrace the use of source control for my personal projects and have settled on git (using Tower as a front-end). Being new to their use however, I was wondering if anyone could give me some tips on "best practices". For example, Suppose I have an initial version of a project committed to a repository. For example, how do I know if I should branch as opposed to simply modifying individual files in the mainline?

Thank you kindly in advance.
 

LimpBagel

Ars Legatus Legionis
11,778
Paul Hill":1muo73ef said:
And don't for heaven's sake do that "dev" "test" "live" branching, it's about the single most retarded release management layout imaginable.

Other than that yeah: commit often, and branch when you think a change is going to run over more than one commit.

What should you do instead of that if you need to quickly roll back to what is live? Branch with a version number when you make a release?
 

levine

Ars Tribunus Militum
1,986
LimpBagel":12g9m7iu said:
Paul Hill":12g9m7iu said:
And don't for heaven's sake do that "dev" "test" "live" branching, it's about the single most retarded release management layout imaginable.

Other than that yeah: commit often, and branch when you think a change is going to run over more than one commit.

What should you do instead of that if you need to quickly roll back to what is live? Branch with a version number when you make a release?
Yes, basically. A product is (ought to be) a single primary development branch. Releases are tagged/named branches which are mostly static, and have gone through a QA process. Bugfixes for releases are applied simultaneously to the relevant release branch + the primary branch.
 

Paul Hill

Ars Legatus Legionis
19,890
Branch HOTFIX from trunk, branch SERVICE PACK from that and then branch LIVE from that. That way it's easy to merge hotfixes into the trunk and out to a CU service pack.


I was thinking more of that ghastly thing where you branch TEST from MAIN then DEV from TEST, work in DEV for ages, then merge it up to TEST and leave DEV to gather cobwebs. That helps nobody.
 

MilleniX

Ars Tribunus Angusticlavius
8,141
Subscriptor++
Commit in small, logical increments, and write meaningful commit messages, in complete sentences and paragraphs. The message should mostly focus on why something is changing, or what the commit accomplishes, and not the mechanics of the change. If you find yourself enumerating tenuously related changes in a commit message, your commit is probably too coarse-grain. It's good to change an API or function prototype and all of its users together in one commit, because it means the code goes from one working state to another. It's not good to have a commit that's effectively "everything I worked on today". Commit messages should never be something like "small change" or "bug fix" or "minor update". Those will be useless to you in a month if you go back and look at them.

Have a look at the text starting "Next, try to" in Pro Git's section on commit practices. The stylistic guidelines there are excellent.
 
Status
Not open for further replies.