Coding of my company has such requirement : You need create a new folder to save your committed code when you complete this task. So how to use JGit api to realize the following git command... git checkout commit_id
Asked
Active
Viewed 90 times
1
-
Thank you,But l just want to checkout it to a new folder not to this repository – shokaku Jan 14 '19 at 10:28
-
The `CheckoutCommand` will always write to the working directory of the repository, just as `git checkout
` would do. Please re-phrase your question if you look for something different. – Rüdiger Herrmann Jan 14 '19 at 11:00 -
The command :"git checkout commit_id" .what l want to checkout is commited files not the whole project in that commit.Sir,do you have any solution – shokaku Jan 14 '19 at 13:07
-
This answer: https://stackoverflow.com/questions/48619755/how-to-clone-a-single-file-with-jgit shows how to get the contents of a single file revision. Further information about accessing Git objects with JGit can be found here: https://www.codeaffine.com/2014/10/20/git-internals/. Alternatively, you can specify the file to be checked out with `CheckoutCommand::addPath`. – Rüdiger Herrmann Jan 14 '19 at 13:42
-
Thanks for your help,sir.My company ask me to copy committed files by commitedid with Java language.My idea is get commited files by comaring two commitId to get filenames.Then copy these files from local repository to a new folder by io.Now l can get filenames,l will complete the coding at tomorrow. – shokaku Jan 14 '19 at 14:37