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
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
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
Old versions of Git will ignore this config value, it will have no impact on the behavior of Git.
Example of the Error
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.
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
git push --set-upstream
--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.
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.