Git pull from specific branch with specified URL

13,137

Solution 1

You need to provide the command git pull web_url branch_name

Solution 2

Add a new remote:

git remote add alt <URL>:/path/to/repo

Fetch the content of the repo:

git remote update

And pull the changes from the branch you want:

git pull alt <branch>

Share:
13,137
Anu Chawla
Author by

Anu Chawla

Software Engineer

Updated on June 04, 2022

Comments

  • Anu Chawla
    Anu Chawla almost 2 years

    I am working on a branch of git. I want to take pull on this branch specifying the URL alongwith it. I have tried

    git pull origin <branch> <url>
    

    but it says error "fatal: Invalid refspec "

    Both commands when ran independently works fine.

    1 ) git pull origin <branch> Takes pull from successfully.

    2) git pull <url> Takes pull from specified URL but from master branch instead.

    I want to take pull from specifying the URL alongwith it so that it doesn't read git's config file and takes pull from 'branch' and 'url'.

  • WEBjuju
    WEBjuju almost 3 years
    i had some kind of golden year moment where i (incorrectly) recalled the correct syntax for <URL>. the url syntax (in a nutshell) IS [email protected]:username/repository.git (NOT [email protected]:repository.git )