G
G
giggigi2012-03-01 22:52:06
git
giggigi, 2012-03-01 22:52:06

Git. Commits to the server?

Hello :)
Recently, I got tired of uploading a project via ftp. It's inconvenient and long. And I decided to use the version control system, namely git. At the same time, version control will not hurt. I work on it alone.
After reading a bunch of articles and manuals, trying it all along the way, I came to the conclusion that I can’t do it myself, and even during working hours.
Please help. Tell me how to do it anyway?
As I understand it, the easiest and most correct way is to commit, then push to the server, and then copy this case to the working directory.
I did authorization via ssh using keys.
I tried everything they suggested, but nothing worked.
All I need is a local repository from which I can push to a remote repository on the server.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

6 answer(s)
M
mithraen, 2012-03-02
@gigigi

1. Create a repository on the server:
$ ssh servername
$ git init-db --bare myreponame
2. Make a clone of the repository locally:
$ git clone servername:myreponame
3. Make sure that the working directory is automatically synchronized by push to the server repository:
$ ssh servername
$ cd myreponame/hooks
$ cat > update
#!/bin/sh -e
refname="$1"
oldrev="$2"
newrev="$3"
gitdir=`pwd`
if [ "$refname" = "refs/heads/ master" ]; then
tmpdir=`mktemp -d`
cd "$tmpdir"
git \
--git-dir="$gitdir" \
archive --format=tar "$newrev" | tarx
rsync -a --delete-after "$tmpdir/" /var/www/whatever/
rm -rf "$tmpdir"
fi
exit 0
4. Don't forget to make this script executable:
$ chmod +x update
5. We make the first commit: on the local machine, go to the repository and do:
$ touch test
$ git add test
$ git commit -m 'test' test
$ git push
6. Check what we got in the working directory, enjoy life

F
Fastto, 2012-03-01
@Fastto

Read - habrahabr.ru/blogs/development/68341/
helped me
put tortoiceGIT a little easier life.
specifically on the question - push to remote is, as it were, the final step, perhaps you did not configure the remote correctly ... what exactly does not work?

S
sajgak, 2012-03-01
@sajgak

Better start with SVN. It is easier to learn and understand + starts up with half a kick. And then, as you get used to it, you can safely switch to mercurial or git

N
No_Time, 2012-03-01
@No_Time

Here everything is simple and clear. Or create a repo on github, then you will have a page on what and how to do and in what order.

I
int03e, 2012-03-01
@int03e

What exactly is unclear?

A
akzhan, 2012-09-26
@akzhan

Install Gitlab + Gitolite, and use Capistrano for deployment,

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question