Commit Command
The commit command saves the changes of the current working files into the repository.
So, when you make some change in a file in your working directory and commit it to the repository, will the changes reflect in the main file in the repository?
Well, the answer is both yes and no. The file is saved in the repository with the same name as the original one. But in fact, it is just a duplicate copy of the original file. The original file will remain intact.
If the name remains same, how will the duplicate file be distinguished from the original one?
Each file in the repository is assigned a revision number such as 1.1, 1.2 etc. This number is assigned automatically, internally. If at any point, one wants to checkout this file, he has to specify the revision number failing which he cannot view the file. The revision number is specified while checking out the file by using the -r option.
What is the advantage of having revision numbers?
The fact that the original file remains intact ensures that you don't accidentally loose any data and apart from that, you can see what changes were made to a particular file, by which user, and when.
The syntax of the commit command is as follows:
cvs commitWhere is the file/folder name?
In case you do not mention the file name, the commit command causes all the files in the folder (and it's sub-folders) in which you have invoked the commit command to be committed to the repository with a new revision number.
Will all the files have a new revision number?
No. Only the files that have been modified will be committed and given a new revision number.
Now, if you want to commit a single file to the repository, the syntax is something like this:
cvs commit filenameOptions of the commit command 1) -l
Only the files in the current working folder are committed. The files in the sub-folder are not committed.
2) -R
Commits the files in the sub-folders also. This option is set by default.
3) -r tag
Commits to the branch with tag tag.
4) -m msg
Saves msg as a message or log to be associated with the file. msg is like a comment or some additional information about the file. By using -m option, editor need not be invoked.
5) -D
This option assumes that all the files have been edited and causes all the files to be checked. The files are only checked and not committed.
6) -n
Does not run any module program.
7) -F filename
Reads the message or log of the file, filename, instead of invoking the editor.
8) -f
It causes the commit command to forcibly commit a new version of the file even if you have not edited the file.
9) -c
Checks for a valid edit on the file before committing.
10) -b bug
Only commits files that have been edited and marked with bug, bug.
11) -B bug
Marks committed files as belonging to bug, bug.
