Click here to Skip to main content
Click here to Skip to main content

Step by Step Setup Git Server on Windows with CopSSH + msysGit and Integrate Git with Visual Studio

By , 7 Dec 2011
 

Introduction

First of all, let me clarify that Git doesn’t need to specify the side for client and server. Your workstation can be both the client and server. That means you can get code from other computer, you’re the client; while others can also get code from your computer, you’re the server. That’s why Git is great.

In this post, the “Git server” means to make your computer available for others to pull/push code from/to.

The post is long because it’s step by step and with lots of screenshots. In fact, it just takes about 10 minutes to setup all.

Note: CopSSH is not open source any more, please buy it if you want to use it.

Software Requirement

Software required to setup a Git server:

  • CopSSH (install on the server side)
  • msysgit (install both on the server side and client side)
  • PuTTY (install both on the server side and client side)

Software required to integrate with Visual Studio:

  • GitExtensions (install both on the server side and client side)

Setup Steps

1. Install msysgit

  1. When you installing the msysgit, please choose c:\Git as the installation directory, because the space in the directory name may cause an issue in bash commands.

  2. In the “Adjusting your PATH environment”, I recommend to select “Use Git Bash only”.

  3. Other settings are default. After installation, you get the git bash icons on your desktop. You can try it with git command, if you get the following screen, you’ve installed the msysgit successfully.

  4. Add C:\Git\bin and C:\Git\libexec\git-core to Path. This step is very important.

2. Install CopSSH

  1. Just like the msysgit, we don’t install the CopSSH in program files folder to avoid some space issues. We install it to c:\ICW.

  2. Just use the default account as CopSSH provides:

  3. After installation, open COPSSH Control Panel.

  4. Click Add button in Users tab.

  5. Choose an existing user on your computer (you can create one in computer management). Here in my sample, the user is jinweijie.

  6. Allow all access:

  7. After the user is activated, click the Keys… button in the Activated Users section:

  8. Click Add:

  9. Use default key settings:

  10. Enter the Passphrase and File name:

  11. The private key will be saved to c:\ICW\home\jinweijie\ryan-vm-01_2048.ppk.

[Test step] Now we try to use the activated user to log on through SSH, open Git Bash, enter commands:

ssh jinweijie@ryan-vm-01 

Enter “yes” to continue.

[Test step] After entering your passwords (the windows account’s password), then you try to run git as the ssh user, but it isn’t performed as you expected:

That’s because CopSSH cannot find the git.exe on the server, so we need to tell CopSSH the git path.

3. Config CopSSH with Git path.

  1. Open C:\ICW\etc\profile with your favorite editor, add :/cygdrive/c/git/bin:/cygdrive/c/git/libexec/git-core (don’t forget the starting colon) to PATH , the whole line will be:
    export PATH="/bin:$syspath:$winpath:/cygdrive/c/git/bin:/cygdrive/c/
    		git/libexec/git-core" 

    Then Save.

  2. Restart the CopSSH by clicking twice the big button in CopSSH Control Panel:

  3. If we run Git Bash again, ssh jinweijie@ryan-vm-01, enter your password and run the git command, git should be found this time:

4. Configure Private Key on Client

  1. Copy the private key (we generated in step 1-k) from server to client.

  2. On the client side, use puttygen.exe to load the key (if you set the password in 1-j, you need to enter the password while loading the key):

  3. Click “Save private key” to save a copy of private key for plink.exe to recognize.

5. Create Repository, Integrate with Visual Studio

  1. Install gitextensions on both server and client.

  2. Since we have already installed the msysgit in step 1-a, we skip the “Install MsysGit”. But if you haven’t install msysgit on the client machine, you can check the checkbox and install it.

  3. Install to C:\GitExtensions\, other settings are default.

  4. On the server side, open Git Extensions, click “Create new repository”.

  5. On the server side, set the path to the project name under you CopSSH user’s home directory, select “Central repository, no working dir” (because we are the server), then “Initialize”:

  6. On the client side, open Git Extensions, click “Clone repository”:

  7. On the client side, the repository address should be ssh://jinweijie@ryan-vm-01/ICW/home/jinweijie/mydotnetproject. Please be aware that, the repository should begin with c:\ on the server.

  8. On the client side, click “Load SSH Key” and load the key which was saved in step 4-b:

  9. On the client side, enter the password if you set password to the key, then click Clone:

  10. On the client side, add ignore files:

  11. On the client side, open Visual Studio, create a project to mydotnetproject folder (which is the cloned repository), you may find the files are already under git source control:

  12. Click the “Commit” button on the menu bar, then click “Commit & Push”:

  13. Push succeeded:

  14. On the server side, you can find the new pushed files:

That’s all, happy GITTING! :)

History

  • 7th December, 2011: Initial version

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

JIN Weijie
Software Developer (Senior) Honeywell
China China
Member
ASTreeView, the best FREE treeview control for ASP.NET.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionRunning copssh on windows 2008 r2 servermemberaliasgar rajpiplawala15 Apr '13 - 19:27 
Hii,

Thanx for the wonderful article. I am trying to install git on my test server so that user can commit from there local machine and file can be pushed to the server directly. I am able to push and pull from the users but i am not able to do it on my remote server. I am facing an issue on step no. k. When i am trying it with administrator i am getting an error as permission denied, please try again. I did google for this but i am not able to get a solution for this and even if i try to make a private key and run it at my machine i am getting an error as you dont have sufficient rights to access this, Its 3 days now i m not able too figure it out please help.
 
Regards,
Ali
GeneralMy vote of 5memberjalalx22 Jun '12 - 21:07 
awesome article! well done!
QuestionGit clone not workingmemberMember 40248005 Jun '12 - 23:38 
Hi lin,
When i clone i got this error,
 
C:\Program Files\Git\bin\git.exe clone -v --recurse-submodules --progress --branch e registry. You "ssh://John@Johnpc/ICW/home/John/dotnetproject" "C:/Myproject/dotnetproject"
Too many arguments.
 
usage: git clone [options] [--] <repo> [<dir>]
 
    -v, --verbose         be more verbose
    -q, --quiet           be more quiet
    --progress            force progress reporting
    -n, --no-checkout     don't create a checkout
    --bare                create a bare repository
    --mirror              create a mirror repository (implies bare)
    -l, --local           to clone from a local repository
    --no-hardlinks        don't use local hardlinks, always copy
    -s, --shared          setup as shared repository
    --recursive           initialize submodules in the clone
    --recurse-submodules  initialize submodules in the clone
    --template <template-directory>
                          directory from which templates will be used
    --reference <repo>    reference repository
    -o, --origin <name>   use <name> instead of 'origin' to track upstream
    -b, --branch <branch>
                          checkout <branch> instead of the remote's HEAD
    -u, --upload-pack <path>
                          path to git-upload-pack on the remote
    --depth <depth>       create a shallow clone of that depth
    --single-branch       clone only one branch, HEAD or --branch
    --separate-git-dir <gitdir>
                          separate git dir from working tree
    -c, --config <key=value>
                          set config inside the new repository

AnswerRe: Git clone not workingmemberJIN Weijie5 Jun '12 - 23:48 
you executed a wrong git command.
ASTreeView, the best FREE treeview control for ASP.NET.

GeneralRe: Git clone not workingmemberMember 40248006 Jun '12 - 0:19 
i am new to git , could you please explain which part is wrong and how to correct it?
thanks.
QuestionFor eclipsememberSpidiudi24 May '12 - 20:19 
The solution given above is only for visual studio projects? or Shall we use it for other ide like eclipse?
I am new to this source control stuff.
help me please.
Thanks and regards
AnswerRe: For eclipsememberJIN Weijie25 May '12 - 5:29 
For eclipse, you can use EGit plugin.
ASTreeView, the best FREE treeview control for ASP.NET.

QuestionCopssh 3.3.3. (Free Version)memberSérgio Sousa13 May '12 - 8:01 
Some Copssh settings refereed at this help are unavailable in free version
 
Can I use this manual with free Copssh 3.3.3?
 
thanks,
SSousa
AnswerRe: Copssh 3.3.3. (Free Version)memberJIN Weijie13 May '12 - 9:48 
I think so, but I am not sure.
ASTreeView, the best FREE treeview control for ASP.NET.

GeneralMy vote of 5memberWillianBR18 Apr '12 - 3:02 
It's work fine. No issue! Thank you!
QuestionMissing: Git Source Control ProvidermemberZ A Tiemoon7 Feb '12 - 8:02 
A very nice article indeed. It helped me
 
I didn't find icon in files and folders in solution explorer of VS 2010. As a result, I could understand whether I have changed any file or not. After googling I found the solution:
 
http://visualstudiogallery.msdn.microsoft.com/63a7e40d-4d71-4fbb-a23b-d262124b8f4c[^]
 
http://gitscc.codeplex.com/[^]
Questionto use other partition than c:memberSome day13 Jan '12 - 3:24 
Use repository address:
<username>@<server_IP_or_name>:X:/path/to/repository 
 
for example to use d:/jinweijie/mydotnetproject
replace ssh://jinweijie@ryan-vm-01/ICW/home/jinweijie/mydotnetproject
to
jinweijie@ryan-vm-01:d:/jinweijie/mydotnetproject

Questionif push to server fails with git <your_path_to_repos> error [modified]memberSome day13 Jan '12 - 3:15 
In GitExtensions open Git bash(Menu->Git->GitBash) and execute below line:
git config --global remote.origin.receivepack "git receive-pack"
 
Lost cca. 4 hours hours to find that out :(

modified 13 Jan '12 - 9:28.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130516.1 | Last Updated 7 Dec 2011
Article Copyright 2011 by JIN Weijie
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid