File talk:Web workflow.png

From FreekiWiki
Jump to navigation Jump to search

Below is a dump of instructions on using git, originally written by Aaron amstutzTonyc

Setting up a remote repo, for Free Geek. Here’s my rundown on how to get this done.

cd into the site’s directory. It’s my understanding that that the site isn’t currently under git, so you have to create a new git repo, containing the site’s files.

git init git add . git commit -m “This is the first commit message on the new repo.”

So now you’ve got the existing site and files under git. Cool! One quick thing to do, then we’ll head towards making a bare public repo. Its advantageous to have some files be ignored by git, like .htaccess, and wp-config.php. The way to do this is create a .gitignore file.

vi .gitignore (Then just add a list of the files you want to be ignored. Here’s the list I used for the dev site.)

.htaccess wp-config.php wp-content/cache/*

Alright, we’re ready to set up the public-accessible repo. I like to have a dir called Git, that way I can just keep all my public repos in the same spot, just a personal preference, but an organizational rule that a lot of people follow. So, cd up to the root of your web server folder, mine’s public_html.

mkdir Git && cd Git mkdir yourproject.git && cd yourproject.git git —bare init

It’ll tell you that it created a bare repository at the location, and now you’re ready to head back to the working repo to add the remote. cd into the site’s directory from your Git directory.

git remote add public path-to-remote-repo/var/www/Git/yourproject.git

If you look in the .git directory, there’ll be a file called config. This holds the repos’ knowledge of remote stuff, and some config stuff for it. Mine looks like:

aaron@chasing-daylight.com [~/public_html/fgdev/.git]# cat config [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true

[remote “public”] url = ../Git/fg.git/ fetch = +refs/heads/:refs/remotes/origin/

You see that the ‘public remote’ points to the repo in the Git dir. Cool. Now check yours. After the previous command, it should point to the public repo. If not, you can just edit the config file to point to it. You can also add any other remote repos you’d like in this file. This can be handy sometimes, but probably not something you need yet.

So now we can push to the public repo:

git push origin public

It’ll output something like: updating ‘refs/heads/public’ from 0000000000000000000000000000000000000000 to b379203bc187c2926f44a71eca3f901321ea42c6 Also local refs/remotes/origin/public Generating pack… Done counting 1374 objects. Deltifying 1374 objects… 100% (1374/1374) done Writing 1374 objects… 100% (1374/1374) done Total 1374 (delta 89), reused 0 (delta 0) refs/heads/public: 0000000000000000000000000000000000000000 → b379203bc187c2926f44a71eca3f901321ea42c6

This takes the refs from our working dir, and pushes them to the repo we named public. We have to update the remote repo after this push, to make it ready to let people pull from it.

cd ../Git/yourproject.git git —bare update-server-info mv hooks/post-update.sample hooks/post-update

Great, now we have a working dir, and a bare repo for people to pull and push from/to. If they have ssh access to the server, they can:

git clone ssh://myserver.com/var/Git/yourproject.git

Do their work, make lots of well-documented commits, and then:

git push ssh://yourserver.com/var/Git/yourproject.git

If they don’t have ssh access, they can clone over http from the repo:

git clone http://myserver.com/var/Git/yourproject.git

Its slower, but works just fine. There is a way to set up pushing over http, via WebDAV, if that’s what you want (See setup-git-server-over-http in the git manual). Otherwise, they’ll have to send you a patch of their work, and you can apply it at your leisure.

Cool! That should do it. Not that hard, right?

I got all my info from the git manual (http://www.kernel.org/pub/software/scm/git/docs/user-manual.html), especially the Sharing development with others section (http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#sharing-development) and from Toolman Tim’s great article (http://toolmantim.com/articles/setting_up_a_new_remote_git_repository) on setting up git repos.