views:

410

answers:

6

On most of my projects, individual or group, I find that I only use version control to simply pull latest changes and post my own code up.

However, I know that there is a lot more to version control, what with branches and other powerful features that I don't use.

Can someone give me advice on how to use version control in a more powerful way?

The version control systems I'm mostly talking about are SVN and Git.

+2  A: 

I find that version control incredibly useful for isolating and fixing difficult bugs. Specifically, by updating to previous versions, I can find out when the problem was introduced, and then find out what changes were made between the two versions, and easily isolate the problem.

Smashery
+13  A: 

You can start here: Red book

You create tags for the things you released; you create branches for the things you are working on and could potentially be wrong/unstable. Your trunk should be as stable as possible (man, that didn't sound right).

Otávio Décio
Thank you for the great link to read.
ojblass
+7  A: 

git ready has lots of tips on using Git, from beginner to advanced. See also the Git Wiki for all kinds of documentation and tips on how to use Git.

Here are a few things that are good to learn about and non-obvious.

Rearrange a series of commits:

git rebase -i <base-rev>

Find which commit broke your unit tests, in this case, make check; you could use any other command that could check for some particular build failure or bug and exit with a non-zero status on failure:

git bisect start HEAD <known good revision>; git bisect run make check

Show useful information about a remote and its branches:

git remote show <remote> 

And branching in Git is easier than anything:

git checkout -b branch-name master # create a new branch, starting it at master
git pull origin master # merge in changes from the master branch on origin server
git checkout master; git merge branch-name # merge changes you made on the branch
git branch -d branch-name # once you're done with the branch

If you want to share the branch with others while you're working on it, or push it to a server for backup:

git checkout branch-name # assuming it's already been created
git push origin branch-name # push the branch to the origin server
Brian Campbell
+10  A: 

Master merging and branching. The thing I find amazing about most uses of version control is that 90% of the people using it don't know how to use it to support two different branches at the same time they use it as a linear versioning system when they check in changes. The real power of version control is that it allows you to effectively maintain two separate versions of a system at the same time which is something that comes in handy when you have to simultaneously support a production version and develop a new version of a piece of software. Learning how to use a tool like Subclipse (and Eclipse plugin for Maven) or a tool like Git to merge changes between branches is something I wish more people using Version Control knew how to do.

tobrien
+3  A: 

Consider putting your build system into revision control. Your tool chain itself may deviate over time and provisioning developer machines becomes comically simply rather than an ordeal. I have also found that versioning test or build artifacts forces you into the discipline of automating. Consider methods of storing other artificats of your software (requirements, milestones, etc). If you have external tools fight duplication with all your might. Consider documenting the build environment within the build system and making it so easy a monkey could boot strap an extract, build, package, advertise, test, package, sign, and deploy.

ojblass
+2  A: 

Read this: http://oreilly.com/catalog/practicalperforce/chapter/ch07.pdf

zvolkov