Is there a way to do git checkout of a single file using IntelliJ's git UI (not console)?
Answered
I've been wondering, is there a way to do git checkout of a single file using IntelliJ's git UI (not console)?
Please sign in to leave a comment.
You can use Git - Show history to select revision, and then Get option of the context menu in history.
But that replaces all the files associated to that commit, doesn't it?
No, if invoked from History of a single file, Get should only checkout the file, not the entire revision.
I'll try that. Thanks!
We have this exact problem, but the file we would like to check does not exist yet on the local branch.
Is there a way to checkout this single file.
Frank,
Could you please provide more details on the scenario?
You want to checkout a single file from some remote branch? This branch should still be available in the Log. Select commit in the log, to see the list of changed files, and from there you will be able to Open repository version, or Show History for Revision, that will give you the same history as shown above.
Hi Dimitriy
Thank you for your quick response.
If the file, say 'Main.java', does not exist in your current branch, you cannot make a check out.
Basically I would like to do is execute the following git command.
git checkout origin/feature/myissue -- src\main\java\org\fb\my\pack\example\Main.java
But the file src\main\java\org\fb\my\pack\example\Main.java does not exist in my working branch
Hope this is enough info
If not do not hesitate to ask again.
Dmitriy,
Your firstresponse was exactly what I was looking for. Thanks!
You also might use this plugin: https://plugins.jetbrains.com/plugin/10795-git-checkout-files-from-branch
I have the same issue as Frank. Just to make it clear (because it wasn't for me the first time I read this) you need to combine both of Dmitriy's answers if the file does not exist in the current branch.
It is a real shame that there isn't an easier way to do this when comparing two branches.