matteosister / GitElephant

An abstraction layer for git written in PHP
GNU Lesser General Public License v3.0
613 stars 74 forks source link

git pull origin #160

Closed AndreFabris closed 4 years ago

AndreFabris commented 4 years ago

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

GenieTim commented 4 years ago

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");.

AndreFabris commented 4 years ago

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

GenieTim commented 4 years ago

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.

AndreFabris commented 4 years ago

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