TortoiseHG - How to export patch for a single file without committing first?

一笑奈何 提交于 2019-12-11 09:42:59

问题


How to export patch for a single file without committing first(working directory)?

this is a possible duplicate, but my question is a little different and that question does not exactly give me a solution for my problem. Also, If I copy a patch how can I use it later? Plus it can be done with a commit only, yes it's a local commit and I can revert it later but is there a easier way?


回答1:


hg diff -g filename >patch will generate the patch. The file can be in the modified or added state, but not untracked. -g is "git" format, and can handle binary files, if needed.

hg import --no-commit patch will import it to the working directory. There can't be other uncommitted files unless you also use -f to force that patch to apply.

Edit per comment:

In TortoiseHg, to export patch for one file in working directory:

  1. Select the commit Window and the working directory.
  2. Right-click the file you want to create a patch for.
  3. Select Copy patch.
  4. Open Notepad or similar editor.
  5. Paste.
  6. Save the file where you want.

To import that patch back to the working directory.

  1. Ensure there are no uncommitted files. Shelve if you don't want to commit.
  2. Select Repository menu, Import patches...
  3. Browse to the patch.
  4. Select "patches will be imported to...Working Directory"
  5. Click Import.
  6. Unshelve if needed.

OR

  1. CTRL-L to open a console in TortoiseHg.
  2. Use the hg diff and hg import commands above. It's easier :)


来源:https://stackoverflow.com/questions/34804230/tortoisehg-how-to-export-patch-for-a-single-file-without-committing-first

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!