git - new user trying to do pull and getting some confusing messages

Git

Git Problem Overview


I am pretty new to git. I have been primarily checking stuff into a repository, but now I want to get the latest changes from another developer.

I tried to simply do a command like git pull something ran, but it came back with a message like this:

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 develop origin/<branch>

So then I did git pull my_branch_name

and it came back with this:

fatal: 'develop' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

but I had done git checkout my_branch right before that.

Could someone please let me know what I did wrong and how I can simply get the latest files that had been checked in?

Thanks!

Git Solutions


Solution 1 - Git

I think you missed the name of the remote when pulling:

git pull <remote> my_branch_name

Run this command:

git remote -v

And check what is the name of the remote you want to pull from

EDIT:

If you are new to Git, I would recommend you this book. It covers from basic to advanced topics, is easy to understand and to read

Solution 2 - Git

As the first error message indicated, you need to tell git where to look when it pulls for that branch:

In Git 1.8 and up, ensure you've checked out develop and run:

git branch --set-upstream-to origin/develop

or the shorter:-

git branch -u origin/develop

In Git prior to version 1.8:

git branch --set-upstream develop origin/develop

Once you've done that you can git pull without having to specify the remote or the branch.

If the remote origin is not yet set up, first run:

git remote add origin url

Solution 3 - Git

try this command:

git pull origin master
git push -u origin master

Solution 4 - Git

You could specify what branch you want to pull:

git pull origin master

Or you could set it up so that your local master branch tracks github master branch as an upstream:

git branch --set-upstream-to=origin/master master
git pull

This branch tracking is set up for you automatically when you clone a repository (for the default branch only), but if you add a remote to an existing repository you have to set up the tracking yourself. Thankfully, the advice given by git makes that pretty easy to remember how to do.

--set-upstream is deprecated in git 1.9.x, apparently. Going forward you'd want to use something like

git branch -u origin/master

assuming you've checked out master already. If not, git branch -u origin/master master will work

Solution 5 - Git

What I like to do is...

$ git checkout master
$ git pull
$ git checkout <remotebranch>
$ git rebase master

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionGeekedOutView Question on Stackoverflow
Solution 1 - GitdavidsView Answer on Stackoverflow
Solution 2 - GitbcmcfcView Answer on Stackoverflow
Solution 3 - GitnavinsView Answer on Stackoverflow
Solution 4 - GitAkash KandpalView Answer on Stackoverflow
Solution 5 - Gituser2493807View Answer on Stackoverflow