matteosister / GitElephant

An abstraction layer for git written in PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

git pull origin

AndreFabris opened this issue · comments

Hi,
after executing $repo->pull($git); where $git is URL to my repository, all works fine. However git status shows that branch is ahead of origin/master by X commits.
This can be avoided by executing git pull origin, however I see no way to accomplish this.
Maybe I am missing something obvious, tried every combination for last two days, with no luck.
Please help

Hi. Sorry to hear that you are having problems. The $repo-pull($from = null, $ref = null, bool $rebase = true) command actually can accept up to 3 arguments. In your case, to finally end up with git pull origin, you can pass as second argument the string 'origin', like so: $repo->pull($git, "origin");.

I tried passing various second arguments, from just a string to a branch. However when I pass "origin" I get:
Exit code: 1 while executing: "LC_ALL=C /usr/bin/git '-c' 'user.email'='admin@appsforce.co.uk' '-c' 'user.name'='AppsForce Administrator' pull '--rebase' 'http://admin@beta.appsforce.org:8080/r/appsforceproject/mydate.git' 'origin'" with reason: fatal: Couldn't find remote ref origin

Okay, I see. I might have to ask a few details about your repo as to the state it is in (output of git remote, git status), but first, let me ask if it works when you just use $repo->pull("origin");?

You might realize in your output posted above how the actual command gets assembled; doing just $repo->pull("origin"); will equivalently result in the command LC_ALL=C /usr/bin/git '-c' 'user.email'='admin@appsforce.co.uk' '-c' 'user.name'='AppsForce Administrator' pull '--rebase' 'origin' being actually executed, which will be more like the desired git pull origin.

Bingo! $repo->pull("origin"); actually works! Many thanks