Montag, 1. November 2010

Use GIT on WebDAV (e.g HiDrive)

I have worked a long time with SVN and now for me was the time to switch to GIT, because GIT offers a lot of possibilibtys I have choose the option to but my remote Retro on WebDAV in this case the HiDrive from Strato.

1.) Install a GIT Client
For Windows I choose "Git for Windows (msysGit)" together with "TortoiseGit" for any other system install the simple GIT Envoriment and it should worked the same way.

Git for Windows (msysGit):
http://code.google.com/p/msysgit/

TortoiseGit:
http://code.google.com/p/tortoisegit/

After you install "msysGit" a small Command Window will show up, you can leave this window open, because we need it or you can open it later manual.

2.) Create a WebDAV User
For HiDrive User, you need to create a new User give him a name like "test-git" and also use a email address, so you will get a notice when you a about to reach the limit.

The User should only has access to WebDAV over SSL, so make sure you check "Use only secure connections" like in the screenshot.

For any other system, make sure that the folder is only avalible over WebDAV and it has a Username and Password.

3.) Prepare a remote GIT folder
Because in most of the case we have no GIT Tools on the Server, we will prepare the remote GIT folder on the local maschine.

On Windows execute the Script "C:\msysgit\msysgit\msys.bat" and a command line should show up.


For other system you have already a shell like bash, sh or any other shell.
Here you go to the location where you want to create the remote GIT folder, please keep in mind you can remove it from your pc after all is working fine, so it could be a temp directory.

e.g:
...
$ cd d:

$ cd TEMP/git-example/

...

When you are in the folder, simple create your remote GIT folder with .git at the end and go into this folder, for e.g:
...
$ mkdir myfirstGIT.git

$ cd myfirstGIT.git/

...

After this we need to init the GIT default files with the simple command "git --bare init" for e.g:
...
$ git --bare init
Initialized empty Git repository in d:/TEMP/git-example/myfirstGIT.git/
...

To make it clear that this is a remote folder, we need to use the additional command "git update-server-info" for e.g:
...
$ git update-server-info -f
...


4.) Upload the prepared folder to the WebDAV location
After you prepared the folder, you can simple copy it to the WebDAV location.
You can simple mount the WebDAV URL and move the folder to this location.

5.) Testing
After you do this, we will test this if all is working correct.

5.1 Create local Git repository
Simple create a local folder, select the folder and then use Git Create repository here from the "TortoiseGIT".

5.2 Copy example files and Commit
After this go into this folder and copy some small files in there.
Then click the right mouse button and select Git Commit > "master", it could be that the tools asked you for your Name and Email so that it is clear who submit the file.

As Message, simple use "My Git Test" and select all file and click on "OK".
5.3 Add the remote repository (WebDAV location)
Now we will add the remote repository, simple go to the TortoiseGit Config to Git -> Remote here you enter the following informations:

Remote: e.g. GITTest
URL: https://[WebDAV Username]:[WebDAV Password]@webdav.hidrive.strato.com/users/
[WebDAV Username]/[GIT Path] e.g: https://test-git:geheim123@webdav.hidrive.strato.com/users/test-git/myfirstGIT.git
Putty Key:

After this simple click on "Add New" and it should be in the list now.

5.4 Submit files to the remote repository
Go back to the folder with the examples files and press the right mouse button and select "Git Sync...", here select your entry under Remote URL.
When it not show up, click on "Manage" and repeat the step 5.3 close the window and open it again.
Because we have no Putty Key, we will uncheck the option, after this click on the "Push" Button.


When all is working fine you should see a message like the following:


5.5 Check out the files on the same or another PC
After this we will check if all is working correct, got into empty folder on your PC and try to use "Git Clone" to check out the remote files.

For the URL, use your WebDAV URL for e.g:
https://[WebDAV Username]:[WebDAV Password]@webdav.hidrive.strato.com/users/[WebDAV Username]/[GIT Path]

5.6 Compare the files
After you have Check out the files, compare them with your orginal folder, when they matched then all is working fine.

6.) Security
For a better security you can use the URL without the [WebDAV Username] and [WebDAV Password] .

Keine Kommentare:

Kommentar veröffentlichen