例如,jgit diff返回1个已更改的文件,我想将其还原为版本化版本。在正常的git我只会
$ git checkout path_to_file
我试过
$ jgit checkout origin/master -- path_to_file
但没有任何变化,没有错误,没有任何内容,文件仍然存在
更新
我试过了:
$ jgit checkout origin/master -- path_to_file
- 无变化$ jgit checkout -- path_to_file
- 无变化$ jgit checkout path_to_file
- 错误:error: pathspec path_to_file' did not match any file(s) known to git.
$ jgit clean
- 想要清除未跟踪的文件,而不是未跟踪的更改$ jgit checkout -f origin/some_other_branch; $ jgit checkout -f origin/master
- 希望这会破坏更改,但只是第二个命令失败,因为“更改将被覆盖”答案 0 :(得分:2)
其实我刚试过,jgit checkout -- path_to_file
对我有用:
~/Development/Eclipse/jgit (master)
$ org.eclipse.jgit.pgm/target/jgit --version
jgit version 4.9.0-SNAPSHOT
$ org.eclipse.jgit.pgm/target/jgit status
On branch master
$ echo "dummy" > pom.xml
$ org.eclipse.jgit.pgm/target/jgit status
On branch master
Changes not staged for commit:
modified: pom.xml
$ org.eclipse.jgit.pgm/target/jgit checkout -- pom.xml
$ org.eclipse.jgit.pgm/target/jgit status
On branch master