Git fetch/checkout without creating remote?

How to fetch/checkout remote repository without creating locally remote branch?

Use Case: I have some repo on GitHub, someone forked it and added new feature and initiated pull request.
I can’t automatically merge it because there are some minor problems I would like to fix first.

  • How to override unmerged git checkout with upstream version
  • Move forward in git
  • Subdirectories in checked out directory of a previous revision not disappearing in Git?
  • Error at git checkout. Path too long
  • meaning of -‌- in git checkout
  • Is it safe to checkout a new git branch during the push of a current branch?
  • It’s one-time activity I’ll never need this remote repository, so I don’t want to create local remote branch.

    Basically I would like to do:

    1. copy files from remote repository and rewrite my own (without any git-related information).
    2. see difference with my current head.
    3. fix something and commit it.

    How to do that?

    git checkout git:// doesn’t works at all (fail with error)

    git fetch git:// works but doesn’t update anything

  • Remove large files on BitBucket
  • View diff of changes since last rebase after pulling
  • Want to exclude file from “git diff”
  • How can I get the associated ref path for a git SHA?
  • http link to download source code from github private repository
  • How to measure IOPS for a command in linux?
  • 3 Solutions collect form web for “Git fetch/checkout without creating remote?”

    You want to use FETCH_HEAD.

    whenever you run git fetch ... a magic reference called FETCH_HEAD is created.

    Try for example:

    git fetch git:// && git merge FETCH_HEAD

    Another neat method (at least on/from Github) is fetching like this:

    git fetch repo pull/7324/head:pr-7324


    repo points to the remote repo, e.g. git://

    pull/7324/head is the remote pull request.

    pr-7324 is the local pull-request branch.

    Then you can use the local PR branch to do whatever you want with it.

    Source: adapted from this discussion.

    For any Git server:

    git fetch git:// remote-branch-name:local-branch-name
    git checkout local-branch-name
    Git Baby is a git and github fan, let's start git clone.