How to use VCS solutions, like SVN or git, to label the version of particular files?

1

so I'm starting to use version control systems (VCS) to keep track of my growing piles of code, and am experimenting with SVN and git. The very basic commands are very similar, so I'll just use SVN as my example.

Say I have a repo with some files in it. After changing a file, I commit the change like this:

svn commit -m "altered the regex to parse properly"

This commits my changes and adds the commit message. However, what if I had just altered 3 different scripts, how can I add individualized commit messages for each of the files?

Similarly, being a version control system, I want to actually keep track of script version numbers. Let's say I start at version 1.0.0, how can I label my changed script as being v1.0.1 upon commit?

So basically, if someone could tell me how to keep track of log messages and version changes for every file when committing, I would be very grateful. Thanks!

jake9115

Posted 2013-09-12T20:03:40.540

Reputation: 1 029

Answers

5

If you want to keep a running change log by file, then you either need to:

  • Create a ChangeLog plain text file in your source tree and type into it whatever info you need (date, time, commit id, summary, etc.) for each file

  • Only commit one file at a time in each commit, this way you will be able to see a commit history in your version control file that lists each file's individual change. This can lead to an inconsistent state of your code though, meaning that if you change two files which depend on one another and only having one file changed leads to an error, you will have broken commits in your code.

VCSes do not typically natively support a per-file commit log while still having commits contain multiple files. You could, however, just put a new line between the description of each file's change in a multi-file commit. Something like this:

Summary: Various bug fixes and updates for Flummox 1.5.2.

file1.c: Updated Flummox API for Flummox 1.5.2.
file2.c: Fix a string formatting buffer overflow.
file3.c: Use new Flummox Advanced Regex engine.

Most people commit each logically isolated change in a commit, regardless of whether it affects 1 file or 1000.

allquixotic

Posted 2013-09-12T20:03:40.540

Reputation: 32 256

2

@allquixotic missed the second part about your question which was about version numbers so here is a answer to that part.

how can I label my changed script as being v1.0.1 upon commit

You don't really label your script as being v.1.0.1, you would probably setup a tag for that commit with the v.1.0.1 label.

In git this could be as simple as something like git tag v1.0.1 <commithash>. Tags in SVN are a bit different, since you use the svn copy feature Doc.

Zoredache

Posted 2013-09-12T20:03:40.540

Reputation: 18 453