質問

I have been using Subversion for years now and am just starting the move to git. My typical setup was to develop on a Windows machine with a local working copy. My IDE would automatically ftp changes to my dev web server. And if I ever wanted to get a clean slate on my dev server I'd run an svn export. I liked this style because it gave me two places where my files resided. I had a bit of redundancy and could wipe out one or the other without fear of it being completely gone. I know committing my changes would do the same thing for me, but that was my little safety net.
Now with git it seems that there is no direct equivalent of svn export. I can git archive, but then that goes to a tar and i have an additional step of untaring it. The only other solution I've come up with has been to put a local git repo right on my webserver's root folder. Could someone tell me if this is standard practice with git? or if there is some alternative that I've missed?

役に立ちましたか?

解決

I assume your web server is linux-based.

Log into your web server and select a path that is accessible from your windows machine.

Create a directory with the name you want to give to your project:

  mkdir my-repo

Go to the directory

  cd my-repo
  git init

This will create a git "project". Now create a root commit on the master branch (I typically create an empty "README" file which is pretty standard on open source projects).

  touch README
  git add README
  git commit -m "initial project commit"

Now from your dev machine, git clone the repo with

  git clone http://<webaddress>/uri/my-repo.git

You can now work on your project and whenever you want to "save" your work, simply use

  git push

Read git documentation for windows as I'm not too aware of how it works on that platform.

Be aware that the "server" project is not an exact copy of the cloned version as it is not self-aware of external clones in that mode. This is how I setup my personnal projects be between 2 linux-based machines.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top