top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Best practice setup for github projects on server

+3 votes
466 views

I was hoping that somebody could give me advice since I'm new to git.

I'll be installing a couple of projects from github on our servers, and adding some features.

Should I create a repository on our server (e.g. in /opt/git/), add the github project as a remote, and create a branch? Then on my local machine add our server as the remote and then pull / push with that?

On the server there will be two web directories: stable and dev. I was planning for these to be branches, and then just pull from the server repository using the local protocol.

I think it would mean sorting out merge actions on the server. I'm hoping to be able to fetch and integrate updates from the developer's github repository, but without making things more complicated than they need to be.

Does anyone have any suggestions?

posted Nov 23, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

I'll be installing a couple of projects from github on our servers, and adding some features.

So you take source code from github and improve it...

Should I create a repository on our server (e.g. in /opt/git/), add the github project as a remote, and create a branch?

You can certainly do that. Why would you want to keep it on your server though? (Is it not worth to be open because it's highly company specific stuff? Is it closed intentionally because it would reveal core company secrets? Is it just for backup, because you don't trust githubs uptime?) Having 2 remotes (github and your server) makes the workflow slightly more complicated, but if you don't mind a complicated workflow that's no problem. But be sure to know why/what benefits you gain from that. You could also go with your github fork, which could be set to private, I'd guess.

Then on my local machine add our server as the remote and then pull / push with that?

Sure, sounds fine.

On the server there will be two web directories: stable and dev. I was planning for these to be branches, and then just pull from the server repository using the local protocol.

Beware of that. There are quite a lot of servers serving the contents of the .git directory, you may or may not want to expose the history. (Certainly it looks odd)
For a private server I'd have the git directory somewhere non-public (outside of /var/www, so maybe in the home directory of the git user) and then a hook like this:

 $cat .git/hooks/post-update
 GIT_WORK_TREE=/var/www/your-stable-web-dir git checkout stable-branch
 GIT_WORK_TREE=/var/www/your-dev-web-dir git checkout dev-branch

That's one way to do it. And outdated by now (as I just wrote down the config I have in a personal server).
Git has learned a push-to-deploy (https://github.com/blog/1994-git-2-4-atomic-pushes-push-to-deploy-and-more ), which should do what you want there, too.

answer Nov 23, 2015 by Jagan Mishra
Similar Questions
0 votes

I'm new to git, and having done a fair bit of reading up I've set up a github account ready to get started.

I plan to combine elements of Inuit CSS (https://github.com/csswizardry/inuit.css ) with Bones (https://github.com/eddiemachado/bones ) to create my own starter framework for Wordpress projects.

My question is should I fork each of these projects and clone them locally, then edit/combine and upload to a new repository? The help info regarding forking appears to imply that you would fork a repository when you were looking to contribute to the original repository rather than create a derivative work, or perhaps that is just the most common use case?

The other option I can see is to just download the repository for each as a zip file, combine/edit and then upload them to a new repository.

Is there a benefit to either route or perhaps another approach that I might be missing?

+1 vote

I was learning to user git-bash and github. As part of tutorial we were asked to set username & password through git-bash command line and create an account in github. But since I already set the email through gitbash global config, I am not allowed to create account or create a password for my account .

Please let me know how can I create a account in github or delete the entry to start fresh.

...