• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Mastodon GitHub Twitter (inactive)
You are here: Home / Dev Tips / Git autoSetupRemote Prevents “no tracking information” Error

Git autoSetupRemote Prevents “no tracking information” Error

Last updated on November 14, 2022 by Sal Ferrarello

After creating a pushing a new branch to GitHub (or any remote), when I do git pull I often get an error that says There is no tracking information for the current branch. The Git config value autoSetupRemote, introduced in Git version 2.38, lets us avoid this entirely error.

How to Set autoSetupRemote to True

Running the following from the command line will modify your global Git configuration to set autoSetupRemote to true.

git config --global push.autoSetupRemote true

After running the above command, if you look in your global Git configuration (~/.gitconfig) you’ll see the lines

[push]
    autoSetupRemote = true

Warning

The Git config value autoSetupRemote was introduced in Git version 2.38, released 2022-10-03, so if you have an older version of Git, this will not work. You can check your Git version by running git --version

Old versions of Git will ignore this config value, it will have no impact on the behavior of Git.

Example of the Error

Before setting autoSetupRemote to true, if I create a new branch (mynewbranch) and push it to the remote (git push), when I run git pull I get the error message “There is no tracking information for the current branch”.

Steps to Reproduce the Error

$ git checkout -b mynewbranch
$ git push
$ git pull
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> mynewbranch

Note: Instead of git checkout -b mynewbranch you can use git switch, git switch -c mynewbranch, to do the same thing.

After Setting autoSetupRemote to True

If you repeat the above steps, instead of the “There is no tracking information…” error, Git will check the remote you’ll get the message

Already up to date.

Explanation

When you run git pull, Git checks its local information to determine what remote branch to pull changes from. Git stores this information in your project in the .git/config file. If Git checks this file and there is no information for your current branch, you get the “There is no tracking information…” error.

By default Git does NOT write this tracking information to .git/config on a regular git push. Instead you need to include the flag --set-upstream (or the short version u).

git push --set-upstream

The --set-upstream flag tells Git to write the tracking information to .git/config, so on a future git pull you don’t get the error.

By setting autoSetupRemote to true, when you type git push without the --set-upstream flag, if the tracking information does not exist in .git/config already, it is written there (i.e. git push behaves like git push --set-upstream).

I have yet to find myself in a situation where this is not the behavior I want.

Sal Ferrarello
Sal Ferrarello (@salcode)
Sal is a PHP developer with a focus on the WordPress platform. He is a conference speaker with a background including Piano Player, Radio DJ, Magician/Juggler, Beach Photographer, and High School Math Teacher. Sal can be found professionally at WebDevStudios, where he works as a senior backend engineer.

Share this post:

Share on TwitterShare on FacebookShare on LinkedInShare on EmailShare on Reddit

Filed Under: Computing, Dev Tips, Recommendations Tagged With: Git, gitconfig

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2023 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in