examining history of deleted file

前端 未结 17 1857
臣服心动
臣服心动 2020-11-30 17:36

If I delete a file in Subversion, how can I look at it\'s history and contents? If I try to do svn cat or svn log on a nonexistent file, it complai

17条回答
  •  情话喂你
    2020-11-30 18:09

    It's nothing particularly special in git. If you know the name of the file, you can find out the change that removed it with log:

    git log -n 1 -- filename
    

    Then you can use that commit to get the file as it existed before the deletion.

    git checkout [last_revision]^ filename
    

    Example:

    dhcp-120:/tmp/slosh 587% ls -l slosh.tac
    ls: slosh.tac: No such file or directory
    dhcp-120:/tmp/slosh 588% git log -n 1 -- slosh.tac
    commit 8d4a1f1a94e4aa37c1cb9d329a140d08eec1b587
    Author: Dustin Sallings 
    Date:   Mon Dec 15 11:25:00 2008 -0800
    
        Get rid of a .conf and replace it with .tac.
    dhcp-120:/tmp/slosh 589% git checkout 8d4a1f^ slosh.tac
    dhcp-120:/tmp/slosh 590% ll slosh.tac
    -rw-------  1 dustin  wheel  822 Dec 30 12:52 slosh.tac
    

    Note that this does not actually put the file back in revision control. It simply drops the file as it existed in its final state into the current location. You can then add it or just inspect it or whatever from that point.

提交回复
热议问题