Sig
Sig

Reputation: 5916

specifying git branch for remote

I'm trying to update my webbynode pulling from github but I got the message below:

You asked to pull from the remote '[email protected]:sigbackup/gsapp.git', but did not specify a branch. Because this is not the default configured remote for your current branch, you must specify a branch on the command line.

So I have checked out this forum for help and I found some comments regarding .git/config file but mine looks already fine (at least to me):

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = [email protected]:sigbackup/gsapp.git
[branch "master"]
        remote = origin
        merge = refs/heads/master
[branch "origin"]
        remote = origin
        merge = refs/heads/master

Am I missing something? Any ideas how I can solve it?

PS I also tried git pull origin [email protected]:sigbackup/gsapp.git and I got

fatal: Couldn't find remote ref [email protected]

Upvotes: 26

Views: 57636

Answers (2)

silk
silk

Reputation: 2734

What local branch have you checked out?

What git status shows?

You are probably working on some other branch than the local master branch. If you want to fetch new commits from github and merge them to the local master branch, you have to:

git checkout master
git pull

If you want those commits in the branch, on which you are working, you need:

git pull origin master

You were close in your try from PS, but the last param should be branch name, not the repo url.


You can also just fetch new commits from github, and do not merge it into any local branch, with:

git fetch origin

Then review those changes with git diff, git log, etc, and merge later to the currently checked out branch with:

git merge origin/master

Upvotes: 26

ulidtko
ulidtko

Reputation: 15560

It's strange that you have a branch called origin. origin is used to name a remote automatically created during git clone; you will get in troubles having to disambiguate origin-the-branch and origin-the-remote. Did you add the branch manually to the .git/config? What commands did you run? I suspect that you messed this up.

Upvotes: 6

Related Questions