Git is a version control system designed for Linux Kernel development. Therefore, it is closely integrated with Linux. This makes it very convenient to use in Linux. But it is not so friendly to those who are used to Windows. Although there are also projects such as msys-git and TortorseGit, it is more and more convenient to use Git on Windows. However, it is inconvenient to share your version library with other people.
In Linux, the clone remote machine version Library only needs:
Git clone user@remote.server.address: path/to/repo local_dir
It can be easily done. Can I Configure SSH on Windows and use git in the same way as Linux?
Yes. First, you need to install two tools:
1-Git: Git in Windows is better than msys-git.
2-SSH: You can use CopSSH to start the SSH service on Windows, not just the client.
There is no difficulty in installing these two tools. It is assumed that Git is installed in the C:/Git directory, and CopSSH is installed in the C:/ICW directory. After installation, git can obtain the version library remotely, and a user can log on to SSH. Assume that this user is git (by default, no user can log on to CopSSH, and a Windows user with a password needs to be manually activated ).
In this case, you can execute basic commands such as ls and cd after logging on from other machines using git users through ssh. However, git cannot run. Therefore, you cannot use ssh to release the git repository. To achieve this, you need to make some settings.
First, you need to find the cmd directory in the Git installation directory, which is C:/Git/cmd. Create the following files: git, git-upload-pack, git-upload-archive, and git-receive-pack. There is no extension here. It is mainly executed by bash after logon. Each file has only one row, which is:
Git. cmd $ *
Git upload-pack $ *
Git upload-archive write git upload-archive $ *
Git-receive-pack write git receive-pack $ *
Then, you need to add a path to the logged-on user to ensure that the command added above can be found and executed. Find the profile file under etc in the installation directory of CopSSH. Here is C:/ICW/etc/profile: Add two lines at the end of the file
Gitpath = '/bin/cygpath C:/Git/cmd' # here is not a quotation mark. The path is cmd under Git. The slash should also be Unix.
Export PATH = "$ PATH: $ gitpath"
Then, use the git user to log on again from SSH. You can use the git command.
For example, create a test database:
Mkdir testgit
Cd testgit
Git init
Touch a B c
Git add.
Git commit-m "init"
Then, you can clone the database remotely. Assume that the ip address of this machine is 192.168.1.1. On another machine,
Git clone git@192.168.1.1: testgit
The clone is successful. In this way, the Git + SSH service in Windows is successful!
Finally, we will explain the limitations that we currently know:
1) link cannot be used, that is, all files must be stored in the git user's home. The location of this home is C:/ICW/home/git.
2) the absolute path cannot be used for clone, but the relative path relative to the git user home can only be written.
Note: The content in the known_hosts file under C:/Documents and Settings/fzt/. ssh needs to be cleared (if any ).