Unfuddle STACK Tips & Tricks
How to fix Git error: There is no tracking information for the current branch.
When performing an operation like
git fetch, etc, without specifying the remote or the branch involved in the operation, you should first make sure that the current branch has a corresponding upstream.
Depending on how the
push.default config is set, you may encounter the following error.
# attempt to pull while the current branch # does not track any upstream branch $ 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> master2
In order to set an upstream branch you can use the
--set-upstream-to option, or the shorthand version
$ git push -u origin master Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 To https://url-to-remote-origin * [new branch] master -> master Branch 'master' set up to track remote branch 'master' from 'origin'.
This operation makes sure that the local
master branch tracks the remote
master branch. We can now pull without specifying the branch remote branch to pull from:
$ git pull remote: Enumerating objects: 5, done. remote: Counting objects: 100% (5/5), done. remote: Compressing objects: 100% (3/3), done. remote: Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (3/3), 328 bytes | 164.00 KiB/s, done. From https://url-to-remote-origin c29db9a..6283d29 master -> origin/master Updating c29db9a..6283d29 Fast-forward README | 1 + 1 file changed, 1 insertion(+)
Here's the Full Official Documentation on branching and remotes in Git.