Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8758255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:29:51+00:00 2026-06-13T14:29:51+00:00

I have a local repository that pulls from a remote one. Running git pull

  • 0

I have a local repository that pulls from a remote one. Running git pull as well as git fetch; git merge FETCH_HEAD used to perform exactly the same action, as is expected from the description of git pull:

DESCRIPTION

Incorporates changes from a remote repository into the current branch. In its default mode, git pull is shorthand for git fetch followed by git merge FETCH_HEAD.

Presently, and unexpectedly, running git fetch stopped updating the FETCH_HEAD reference correctly. FETCH_HEAD is now stuck to an old commit. Running git fetch downloads all changes to remote tracked branches, but FETCH_HEAD remains unchanged regardless of the branch in which it is run.

# currently in branchone
> git fetch

# branchone is up to date since...
> git rev-parse branchone
593539e8a98ba5980d4b645db3b0f506bb9b6a2c

# ...its in the same commit as the remote branch
> git rev-parse origin/branchone
593539e8a98ba5980d4b645db3b0f506bb9b6a2c

# however FETCH_HEAD shows something different
> git rev-parse FETCH_HEAD
37301df96597ac037f8e7e846fea6fc7df77bea5

git pull still performs the correct task. However running git fetch; git merge FETCH_HEAD will do something different since FETCH_HEAD points to an incorrect commit.

Is there any setting or issue that could be messing with git fetch behavior?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T14:29:53+00:00Added an answer on June 13, 2026 at 2:29 pm

    Running git fetch without any options will fetch all references in the remotes and write them to the .git/FETCH_HEAD file. The contents of the file usualy looks something like this:

    37301df96597ac037f8e7e846fea6fc7df77bea5 branch 'master' of github.com:user/repo
    593539e8a98ba5980d4b645db3b0f506bb9b6a2c not-for-merge branch 'branchOne' of github.com:user/repo
    

    When you have a file like this under the .git directory, you can use it as a reference as long as the first thing in that file is either a 40 character hex number, or a shorter hex number that actualy matches to an existing commit.

    # This file can be used as a reference
    > cat .git/MAGIC_HEAD
    deadbeefdeadbeefdeadbeefdeadbeefdeadbeef lorem ipsum
    the rest does not really matter
    refrigerator
    
    # And thus it will be interpreted by many git commands like this
    > git rev-parse MAGIC_HEAD
    deadbeefdeadbeefdeadbeefdeadbeefdeadbeef
    

    Knowing this we can see that after running git fetch the reference FETCH_HEAD will resolve to is whatever happens to be in that first line

    # Assuming the already mentioned contents of .git/FETCH_HEAD
    > git rev-parse FETCH_HEAD
    37301df96597ac037f8e7e846fea6fc7df77bea5
    

    Seems like the order of the contents of .git/FETCH_HEAD is not guaranteed to contain first the reference for the current branch.

    By trying it in different repositories it seems that in some the first line is always the current branch, and thus git fetch; git merge FETCH_HEAD works as expected. On other repositories however the contents of .git/FETCH_HEAD will be ordered differently and often the first line will be a reference to the remote commit of a different branch, thus making the FETCH_HEAD reference incorrect.

    Why it behaves differently is a mystery to me.

    As a solution, if git fetch remote_name branch_name is used only this specific branch is fetched and only that single line will appear in the contents of .git/FETCH_HEAD, making the FETCH_HEAD reference always correct.

    # Will only fetch branchone
    > git fetch origin branchone
    
    # FETCH_HEAD will contain only a single line
    > cat .git/FETCH_HEAD
    593539e8a98ba5980d4b645db3b0f506bb9b6a2c branch 'branchOne' of github.com:user/repo
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Git repository on my local machine that I cloned from my
Totally new to Capistrano. I have a local git repository that I want to
I have a local branch that is tracking of a remote branch on git.
I have a remote tracking branch tracked locally in my local repository using 'git
I have a central repository and 3 users with local repositories that pull and
Say I have an arbitrary local git working directory that was cloned from some
I have a repo that's forked from a remote repository. I made some changes,
Here's the scenario: I have a local git repository that mirrors the contents of
I have a local repository I'm working on and its remote is hosted on
I have repository on GitHub to which I commit regularly from my local computer.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.