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)?

10 comments
Comment actions Permalink

You can use Git - Show history to select revision, and then Get option of the context menu in history.

1
Comment actions Permalink

But that replaces all the files associated to that commit, doesn't it?

0
Comment actions Permalink

No, if invoked from History of a single file, Get should only checkout the file, not the entire revision.

0
Comment actions Permalink

I'll try that. Thanks!

0
Comment actions Permalink

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.

0
Comment actions Permalink

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.

0
Comment actions Permalink

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.

1
Comment actions Permalink

Dmitriy,

Your firstresponse was exactly what I was looking for.  Thanks!

0
Comment actions Permalink

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.

0

Please sign in to leave a comment.