Reputation: 29517
My process for creating a new GitHub repo (with only a master
branch) is as follows:
From the terminal:
git init
git add .
git commit -m "Initial commit"
Then I go into GitHub and create my new repo, which creates a Git URL for it, say, https://github.com/myuser/myRepo.git, etc. Then I go back to the command line:
git remote add origin https://github.com/myuser/myRepo.git
git push -u origin master
At this point, I typically like to create a develop
branch off of master, and then use that develop
branch to subsquently cut feature branches from it (thus keeping master
"clean" and so that it only changes when I have prod releases):
git checkout -b develop
git push origin develop
At this point I can go onto GitHub and see that my remote repo now has both a master
as well as a develop
branch.
git pull
git branch --set-upstream-to=origin/develop develop
Now, if I try to make any changes to develop
and then push them, I get the following error:
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/develop develop
I'm wondering what it means to not have any "tracking information" for my current branch? That is, if I have create a branch locally, and pushed it, then why do I have to add tracking information to it, and what does "adding tracking information" even really mean?!
Upvotes: 2
Views: 2861
Reputation: 76
When you push the newly created develop branch to GitHub using
git push origin develop
it copies the commits from the local branch to the origin remote, creating a remote develop branch. However, git doesn't automatically save the information that the local develop branch should track (or push to) the remote develop branch. This can be done in two ways:
1) When you first push the newly created branch:
git push --set-upstream origin develop
2) Using the --set-upstream-to option, as suggested by git, after you have already pushed the develop branch:
git branch --set-upstream-to=origin/develop develop
After doing either of these, that message will disappear and git will now use the remote branch develop by default (or track it) when you git push on the develop branch.
More info:
Edit: git push --set-upstream is the same as git push -u, which is what you used to push the master branch.
Upvotes: 2