Last Updated: February 25, 2016
·
3.634K
· antjanus

Git Fetch as alternative to Git Pull on shared hosting

If you're using Git on shared hosting, you may encounter some issues with the command "git pull". This command may not be available to your limited shell access that you get.

Instead of using git pull, do this:

git fetch | git merge origin/master

This will fetch the latest changes and push them into your local git repository.

3 Responses
Add your response

In the git man pages it says this:

More precisely, git pull runs git fetch with the given parameters and calls git merge to merge the retrieved branch heads into the current branch.

So is this not doing the same thing?

Personally I am a fan of git fetch | git rebase origin/master Which will take any commits I've done and force them to the end of the history. This works especially nice in feature branches (I never commit to master, branches are cheap) because you don't get the annoying merged master commits and allows you to keep local master completely clean and in parity with origin/master

The flow in a feature branch would look something like this.

A--B--D  - master (parity with origin/master)
    \
     C--E  - local feature branch

Running git fetch | git rebase origin/master will then produce

A--B--D - master
       \
        C--E

Which once it is merged with master will look like

A--B--D--C--E
over 1 year ago ·

Right, that's my point. git pull however does not work via SSH in jailshell so you have to do a manual git fetch | git merge origin/master. It's not really documented anywhere (the jailshell problem) so I wanted to post it as a tip for shared hostings.

I like your rebase idea, I'll implement it in my workflow. Might be a better alternative if you only work one-way. Thanks! :)

over 1 year ago ·

Ahh. That makes more sense than, haha

over 1 year ago ·