问题
I have a file that is locked/checked out exclusively by a user who is no longer with the company. I need to make changes and want to know how to "steal the lock".
回答1:
Ask your perforce admin to remove the lock by issuing
p4 unlock -f <file>
PS: To reuse the departed user's license, your perforce admin might also want clean up the files left opened by him. He can revert the pending edits if they are useless or transfer them to another user via "p4 reopen".
The "reopen" and "revert after reopen" can also be performed by ordinary users.
回答2:
"Locked" and "checked out" are two different things which require two different operations to undo. As Peter G. said, an admin can unlock a file with the unlock command:
p4 unlock -f <file>
However, to revert a file checked out by another user, you need to impersonate that user by passing their client (workspace name), host (computer name) and user names to the revert command, like so:
p4 -c theirclient -H theirhost -u theiruser revert filename
So if a Perforce user named jdoe has file foo.txt checked out in workspace ws1 on a host named joesPC, an admin can revert it with the following command:
p4 -c ws1 -H joesPC -u jdoe revert foo.txt
回答3:
You have three choices, and if you don't know the user's password all three will require an admin.
p4 unlock -f filename
- this will only work if you are an admin. Also, it will not work on files with a
+l
filetype, such asbinary+l
—in such a scenario it will need to be reverted.
- this will only work if you are an admin. Also, it will not work on files with a
With the user's password (get a p4 admin to clear it out if no one knows what it is), use a command like the one raven suggested:
p4 -c theirclient -H theirhost -u theiruser -p theirpassword revert -k filename
Or without the password, get an admin to use this sequence:
$ p4 login theiruser User theiruser logged in. $ p4 -c theirclient -H theirhost revert -k filename
回答4:
Some dummy users may checkout the entire depot and lock all the files:
If you have admin access then you can use:
p4 client -d -f clientname
Where clientname is the name of the workspace.
来源:https://stackoverflow.com/questions/3875303/perforce-file-locked-by-departed-user