开发者

How to discard perforce integration history for a newly-branched and edited file?

开发者 https://www.devze.com 2023-01-06 08:33 出处:网络
Let\'s say I\'ve branched a file in perforce and edited it. Now I\'d like to discard the branch history and treat the file as a fresh add. What command accomplishes this?

Let's say I've branched a file in perforce and edited it. Now I'd like to discard the branch history and treat the file as a fresh add. What command accomplishes this?

This scenario arises often because my IDE insists on treating a copy as a b开发者_如何学Cranch/edit. After making extensive changes to the copied file, it causes confusion to treat it as a branch/edit.


You can revert the new file and then add it back, without the copy/move.

cp /path/to/new/file /path/to/new/file.bak
g4 revert /path/to/new/file
mv /path/to/new/file.bak /path/to/new/file
g4 add /path/to/new/file

But, the history is there for a reason. If one exists, you might want to keep it - it might be helpful to see the lineage (even if muddled) at some point in the distant future. Consider changing your settings on your IDE.


In your IDE:

  • Create a new file with the new name
  • Open the old file
  • Select the contents of the old file
  • Copy to the clipboard
  • Open the new file
  • Delete all the contents from the new file
  • Paste in the contents of the old file.

Then the IDE will do a new in perforce instead of a branch, the above is only a few keybaord presses if you use your IDE keybaord shortcuts.

0

精彩评论

暂无评论...
验证码 换一张
取 消