使用命令行 jgit,如何将单个文件检出回其 git 版本?
With command-line jgit, how to checkout a single file back to its git version?
例如 jgit diff returns 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
- 希望这会压缩更改,但随后第二个命令失败,因为 "changes would be overwritten"
- ...还有很多我不记得了:)
实际上我刚试过,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
例如 jgit diff returns 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
- 希望这会压缩更改,但随后第二个命令失败,因为 "changes would be overwritten"- ...还有很多我不记得了:)
实际上我刚试过,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