Adding files to source control on Linux and UNIX

Before you can create a new element, or add an existing element to source control, you must check out all parent directories of the element using the cleartool checkout command. To retain the parent directory of the view-private file that is being created as a new element, you use the -mkpath option in the cleartool checkout command.

You add a file to source control by using the mkelem command. This command creates one or more new elements. By default, this command will check out the element to your view.

If the element already exists as a view-private file, use the -checkin option to create the new element using the view-private file. To preserve the modification time of the file being checked in, use the -ptime option. If you omit the -ptime option, the modification time of the new version is set to the checkin time.

For example, to add a view-private file named foo.c to source control that is located in the bin directory, you would do the following:

  1. Checkout the bin directory:

    cleartool checkout -mkpath bin

  2. Add foo.c to source control and retain the file's modification time:

    cleartool mkelem -checkin -ptime foo.c

You should not forget to check in the parent directories when you are done, using the cleartool checkin command!

Try it!

Note: To have a file to use for learning to check in and out, you will first create one in /var/tmp/your-username_tut_elements_vob.
  1. Navigate to the VOB /var/tmp/your-username_tut_elements_vob.
  2. Use your favorite text editor, and create a text file containing your name.
  3. Save the file using the name author.txt. Then close the editor.
  4. Check out the parent directory of the author.txt file by typing this command at a system prompt:

    cleartool checkout your-usename_tut_elements_vob

  5. To add the view-private file author.txt to source control under, type this command:

    cleartool mkelem -ci -ptime -co "initial content" author.txt

Optional. Review the reference page for the cleartool mkelem command and display it in a Web browser by typing this command: cleartool man -gra mkelem