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.
Written by Antonin Januska
Related protips
3 Responses
In the git
man pages it says this:
More precisely,
git pull
runsgit fetch
with the given parameters and callsgit 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
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! :)
Ahh. That makes more sense than, haha