Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

specifying git branch for remote

Tags:

git

github

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]

like image 754
Sig Avatar asked Feb 09 '11 10:02

Sig


People also ask

How do I point a local branch to my remote?

When you're publishing a local branch. You can tell Git to track the newly created remote branch simply by using the -u flag with "git push".

What is a remote branch in git?

Git checkout remote branch is a way for a programmer to access the work of a colleague or collaborator for the purpose of review and collaboration. There is no actual command called “git checkout remote branch.” It's just a way of referring to the action of checking out a remote branch.

How do I add a remote to a branch?

Push a new Git branch to a remote repo Clone the remote Git repo locally. Create a new branch with the branch, switch or checkout commands. Perform a git push with the –set-upstream option to set the remote repo for the new branch. Continue to perform Git commits locally on the new branch.

Can I switch to a remote branch git?

In order to switch to a remote branch, make sure to fetch your remote branch with “git fetch” first. You can then switch to it by executing “git checkout” with the “-t” option and the name of the branch.


2 Answers

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
like image 102
silk Avatar answered Oct 20 '22 23:10

silk


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.

like image 24
ulidtko Avatar answered Oct 21 '22 00:10

ulidtko