Undo remove file in ClearCase

前端 未结 3 494
抹茶落季
抹茶落季 2020-12-06 05:34

I have a ClearCase view with a folder, and two files. I check out the folder, remove a file and check the folder back in. I am left with one folder and one file. Is there a

相关标签:
3条回答
  • 2020-12-06 06:28

    To add to the earlier comments, I would suggest that instead of "removing" elements from ClearCase, simply rmname them. This way you don't actually remove the files but hide them. You can use the rmname command again to retrieve (unhide) the files in the future.

    0 讨论(0)
  • 2020-12-06 06:31

    Yes, it is possible to get the file back. This is an important feature of ClearCase (and a life-saver on occasion).

    Let's say that your directory is /vobs/somevob/somedir. The version of the directory with two files in it was /main/3; the version with one file was therefore /main/4. The dropped file is /vobs/somevob/somedir/crucial. Assuming ct is an alias for cleartool, you then do:

    cd /vobs/somevob/somedir
    ct co -c 'Recover file crucial' .
    ct ln .@@/main/3/crucial .
    ct ci -nc .
    

    The first line means I don't have to type the path to the directory in the other three commands; otherwise, it is optional. The second line checks out the directory so it can be edited. The last line checks in the modified directory. The third line is where the magic occurs...

    The ct ln .@@/main/3/crucial . line identifies the file crucial that was seen in version /main/3 of the directory . and links it to the current directory (the checked out version of the directory). The file version you see will be the one chosen by your cspec, but the correct file is in the view (assuming you do in fact pick up /vobs/somevob/somedir@@/main/5 with your cspec).

    (Note that you aren't limited to doing the link one version back; you can reinstate a file after 10 years and 20 versions if you need to. Although you can link a file to two directories at once, that is highly unrecommended; use a symlink instead. You could recover a deleted file into a different directory from its last known location.)

    0 讨论(0)
  • 2020-12-06 06:39

    To add to Jonathan's answer:

    • you can do every step he describes in a graphical way, through the version tree of the parent directory: merge from the version which still references your file to the version to the current version (which doesn't reference anymore your file).
      Do a merge "graphically" (select the option "graphical merge")
      You can then select the file you want to restore.

    • you can also remove the effect of your last checkin (still for the parent directory) through a merge -delete:

    Caution: If more than one change was made to the directory in this version, those changes could be reverted as well. Use the cleartool lshistory command to determine what other changes were made to that directory version.

    1. Determine the version where the element was rmnamed.
    2. Use cleartool merge -delete to remove the changes applied in that version of the directory.

      For example:

      cleartool merge -to . -delete -version \main\17
      
    3. If the only change made in this version was the removal of the desired element, the change should automatically be made (see about caution).

    0 讨论(0)
提交回复
热议问题