How to run Git server on Windows? - windows

How can I share a Git repo on Windows? The "correct" ways appear to be to run "git-daemon" (unix specific) or run ssh (unix specific) or run an http front end for Git. If I just have two Windows boxes and don't feel like installing Unix just to run Git, what is the optimal way to share the repos between the two boxes?

If both machines are in the same LAN, you can put the repo in a directory shared via the regular Windows network protocol (SMB).
(Disclaimer: I'm not certain about locking semantics for SMB, so it could be that simultaneous writes to the repo could corrupt it. Then again, the same probably holds for Unix.)

If you want easiest way, you have to see at SCM-manager
The easiest way to share and manage your Git, Mercurial and Subversion
repositories over http.
In order to have http-served repository with nice Web-frontend and management you have to have only Java (Java, not JRE)

Another alternative instead of running a virtual machine is to run all the Unix stuff in Cygwin. With Cygwin you can set up an ssh server on your windows machine as well as gitolite. And it runs natively on your hardware instead of a virtual machine.
Cygwin installation is very straight forward. It's just a single executable that downloads the packages you need. Keep the installer around because it's what you'll use to add and remove software in Cygwin.
Running gitolite on Cygwin is not as simple but just google "cygwin gitolilte" and you'll find lots of tutorials.

Git is a distributed version control system. So, in most situations, you don't need a dedicated program to serve the content in the repository, you just need a way to access the repository from both machines. One way of doing this is like #thomas suggested and placing a clone of the repository in a shared network location.
Another way that I have found successful in the past as a broke graduate student, is to use Dropbox as the "master" repository. Basically, you git clone your repository into your Dropbox directory, then you can setup Git on both machines to push/pull from the Dropbox repository. Dropbox will do the syncing magic in the background. This only works for mildly active repositories.

What I have done in the past is just run a VM with a small linux client on one machine through virtual box. You only need to port forward the ssh port and you're good to go - no need for configuring the network to something complicated on the VM.
This will allow you to run things like gitolite to manage users.
For this and many other reasons, I've switched to running Linux for all my machines and just run windows in a VM when I need to do Windows development. Lots of great services that you can run on Linux are more easily connected to from the guest OS than the other way around.
If you will have only the 2 windows machines, you can add a url to the remote, but ensure it is done via the file protocol. ie:
git remote add origin file:///\\some-server/share/repo.git
Some people claim that if you use just a path, git will try to make hard-links between the 2 repos. AFAIK, msysgit does not do this and you can use a path with no file protocol:
git remote add origin /z/somepath/repo.git
if z is mapped to a share on the other machine. I didn't need to run a server in your scenario.

Related

How can I prevent git corruption on linux virtual machine?

I have a virtual machine (Virtual Box) on a Windows host running Linux on the guest.
I have a git repo on the client with file sharing set up with Samba in such a way that it's in my Network Locations.
I run SourceTree as my git client from my Windows host to affect the repo on the VM.
The issue is that every once in a while, the git objects on my guest get corrupted. I have already found (and keep finding) ways to fix the git repo after it's corrupted. I have fixed it, and it works. The issue is that the fix removes my uncommitted changes so I have to back up every time.
My question is, how, if possible, can I PREVENT the corruption of those git objects?
It should be noted that:
I don't force-shut down the VM.
I have tried turning off auto-refresh in Source-Tree.
I am aware that I can back up the git files at the end of every work session and avoid losing progress like that but that's annoying.
I am open to any suggestions.
Working with two different git executables (one for Windows and one for Linux) on the same repository sounds like a bad idea.
Git is by design a distributed VCS, so you can take advantage of that. Just have one clone of the repository in your Windows filesystem, and one in your Linux VM. then have a bare repo (git init --bare) on your Linux VM where you can push your work and pull work from the other repo. Use ssh from the Windows host to push changes, not samba. Be aware that while it is possible to directly push between two non-bare repositories, it is not recommended (for example, you cannot push to the current branch of a non-bare repository).
If, by any chance, you have access to a web-based git service (GitHub, gogs, GitLab, …), you can also use that for pushing and pulling.

GIT GUI client on Windows for Unix GIT installation

Our company programs and runs data analysis on a Linux server. The programming is done in Windows clients (SAS, generally). Each project is only programmed by one person and is reviewed by another.
We would like to put our projects under version control but leave the code on the server (ie not pulling to local Windows repositories). The advantage is incremental backup and helps with confirming changes from the reviewer.
Does anyone know of a Windows client that can read remote repositories but perform GIT actions using GIT on Linux, rather than on Windows? Trying a few clients (e.g. SourceTree and SmartGIT) suggests only the latter is possible.
Thanks, Rich
One way to achieve what you want is to export the directories containing the Git repositories on your server over CIFS (via Samba) and then mount them as network disks on your workstations.
But really I can't understand what's wrong with using Git the normal way.
Deployment is best done using native packages for the target system (hard to do on Windows, I admit) or a tar.gz archive (doable using git archive) or a tool like git-ftp or rsync.
If you need code review, consider using Gerrit.
As to backups, each Git repository clone is, in a sense, a set of differential backups of itself. That is, the more (local) clones you have the safer you are.

How to avoid physical path in bzr+ssh://myserver/C:\mydir?

I am starting with Bazaar (switching from Subversion, sorry if terminology is a bit off sometimes). Using Bazaar locally no problems.
Got bzr+ssh:// working on my Windows server (finally! and even ssh agent is working wow!)
Now I want a shared repository on the server from which the developers can branch to their machines. I want the repository in a specific folder, for example in C:\bzr\MyProject.
When I do:
bzr init-repo --no-trees bzr+ssh://myserver.com/MyProject
it creates the repository in C:\cygwin\home\user\MyProject in the home directory of my user account - it is understandable, but worrying.
Then as an experiment I also tried and succeeded:
bzr init-repo --no-trees bzr+ssh://myserver.com/C:\bzr\MyProject
This created the repository where I wanted. But how do I "map" or "alias" the URL (or bzr) so my developers can logon under their accounts and use URL
bzr+ssh://myserver.com/MyProject
to access the shared repository in C:\bzr\MyProject?
Obviously I don't want developers to use bzr+ssh://myserver.com/C:\bzr\MyProject because of the physical path in the URL.
Ok my own answer is if you want to run Bazaar on a Windows server for a development team who will access it over the internet,
and you are not familiar with Linux, Cygwin, SSHD and related stuff then it might turn out more complicated than you can bear.
I actually abandoned the Bazaar idea and gone with Mercurial. I must say Mercurial install on the server is also steep, but at least it is just Windows, IIS and only a bit of Python. Got it running in half a day.
Some of the problems that I had with bzr+ssh:// on a Windows server are:
Needs SSHD installed on the server. SSHD (from stripped down Cygwin) supplied with Bazaar refused to work. Had to install Cygwin and learn a bit of Linux stuff, how to run as a service, how to configure, how to generate keys.
Hard to add a new user in a way that does not request passwords typing for each command. Will need to generate a keypair, mock with copying the keys to th server in two locations (Cygwin's home user folder and Window's too). Probably need to log on the user to Windows to create a profile. Don't want developers logging on to the server actually.
Hard to set up a shared repository in a specific location on the server. Does not seem possible with bzr+ssh. Possible with sftp. Might need to use symlinks as bialix suggested above.
As a newbie to linux stuff I don't understand all implications of running sshd on the server and giving shell access to the developer accounts. Have to use bzr shell limited... documentation is scarce.
Basically, bzr+ssh:// on a Windows server seems to be what installing Subversion on a Windows server was like several years ago - hard. Hopefully it will get better with Bazaar too because I chose it over Mercurial initially.

How to setup PC and Mac for using git

I use git both for Mac and PC.
When pulling Mac's git from PC, it's easy as I can use ssh.
git clone smcho#prosseek:~/smcho/setup
The problem happens the other way round : to pull from Mac. I guess there are two ways to go.
Method 1 : Connect to server
By using 'connect to server' in Mac, I can make PC's directory like that of Mac. Even though, the file permission issue, it works pretty well.
Method 2 : ssh
I could run cygwin ssh server (cygrunsrv -S sshd) to be accessed from other computers, but for me, I have to wait quite a while to get connection as I explained here. It's almost impossible for to use it with git, as I don't want to wait for minutes to get clone.
Here comes my question.
Is there any better way other than the previous two methods?
Is there a (natural) way to support ssh server from Windows (windows 7 precisely) not using cygwin?
I've started using the philosophy of trying to stick in the native environment that something is designed for.
With that in mind, my windows box has an ubuntu server virtual machine that hosts my git repositories. The nice thing is the linux + virtual box + git is an awesome source repository that is completely free. No extra machine and you can give it very little memory so it isn't a resource hog.
There is even another option:
If you use both computers for developing and just want to keep the repositories in sync, you could create a bare repository and use something like Dropbox to synchronize it.
I see two other solutions :
using a third synchronisation server: GitHub, the most famous (if your program is OpenSource), but you can also find free online private Git repositories
on Windows, you can set up the Git server ('git daemon' command). On MAC, you'll access to the Windows repository using the URL git://ip_of_windows_machine/repository/
You might consider another approach entirely. If you're using git as a revision control system that you might consider a hosted account for mastering your repository, maintaining backups, etc. http://github.com/ is the leader in the space for git.

Modifying files on remote Ubuntu server from Windows PC

I am developing some Python programs that I'm running on a remote Ubuntu Linux server (hosted on Slicehost). I would like to work on the source in an IDE on my Windows Vista PC, and have all file modifications sent directly to the Linux box without my intervention (i.e. without having to manually SFTP the files each time I change them). What is the very easiest way I can do this?
WinSCP includes a basic remote file editor, though if you want to use a proper IDE for your development this won't be much help.
I'd suggest you run a version control system like subversion, which would allow you to write a post-commit hook to automatically rsync your code the server with each commit.
Use PuTTy and SFTPDrive.
PuTTy is an SSH client, and SFTPDrive ($39 USD) will allow you to mount your remote file system locally as a drive letter.
Install Samba and OpenVPN on the server, and OpenVPN on the client. Setup Samba to share the directory tree you're interested in, and access it over the VPN for security. Perhaps Vista has non-sucky WebDAV support by now, and you could use WebDAV over HTTPS, but it was always crap under XP.
Ben's suggestion of a local dev environment using a VM is also a winner.
You could install cygwin and then have rsync run on cron every minute.
Or you could use Netdrive to access the server via FTP like a local disk:
http://tech.xptechsupport.com/netdrive-turn-your-ftp-into-a-drive-letter.html
Or you may be able to achieve something similar using cygwin and FUSE - you can on linux, but never tried it on cygwin.
Also, would it not be easier to set up a full dev environment locally? Maybe using a virtual machine? It'll be much quicker for testing. And then you can set up a shell script to transfer the current version to the slicehost server.

Resources