windows上git/github安装,有几个选择,一个是msysgit,还有一个是GitHub for Windows。其他还有cygwin这里就不介绍了。另外GUI工具有tortoisegit,sourcetree等等。
1.下载安装[url=https://github.com/msysgit/msysgit/releases/]msysgit[/url]
2014/04/12更新: 官网已经从googlecode迁移到github了。下载最新版msysgit1.9.4.
在安装过程中会询问是否修改环境变量,选择Use Git Bash Only
[img]http://dl2.iteye.com/upload/attachment/0088/6442/bed83a37-15e3-3ba4-8e2d-138056d9d86a.jpg[/img]
SSH选择用git自带的就可以了。
[img]http://dl2.iteye.com/upload/attachment/0088/6444/57dde65e-76ee-3d66-a29f-df24224076a3.jpg[/img]
还会询问换行符的转换方式,使用默认设置就可以了。
[img]http://dl2.iteye.com/upload/attachment/0088/6446/c01cdd93-787d-3b59-b0ae-53ce7fa4c76a.jpg[/img]
2.如果只是要命令行操作,msysgit就够了。如果要GUI操作,可以下载安装[url=http://code.google.com/p/tortoisegit/]tortoisegit[/url]或者[url=http://www.sourcetreeapp.com/]sourcetree[/url]等等其他工具。
3.如果要操作Github的,还没账号的话去[url]https://github.com/[/url]注册吧
4.配置
参考[url]https://help.github.com/articles/set-up-git[/url]
$git config --global user.name "Your Name Here"
$git config --global user.email "your_email@example.com"
请确保 name 和 email 信息与在 GitHub 注册时的信息相符(当然每个项目还是可以单独设置的,比如你自己公司的私服你可以在项目里重设name和email)。
紧接着创建一个 SSH Public Keys,输入:
ssh-keygen -t rsa -C "username@email.com" 回车后,你会看到类似画面:
Generating public/private rsa key pair. Enter file in which to save the key (~/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in ~/.ssh/id_rsa.
Your public key has been saved in ~/.ssh/id_rsa.pub.
The key fingerprint is: e8:ae:60 ......
此时,你需要的 SSH Public Keys 就保存在 id_rsa.pub 文件中,找到并打开它,将里面的代码复制到 Account Settings 的相应区域(github网站上)。
5.如果对上面的操作不熟悉,可使用GUI工具创建ssh key
5.1 github提供了一个简便的工具GitHub for Windows
[url]http://github-windows.s3.amazonaws.com/GitHubSetup.exe[/url]
下载安装,并按照提示简单的几步就创建好了一个shh key,创建好的key在如下目录
C:\Users\xxx\.ssh\github_rsa.pub
而且在https://github.com/settings/ssh上面也可以看到。
5.2 msysgit自带一个gui工具可能更好,打开Git GUI,帮助->Show SSH key,点击generate key也可以生成。
6.如何下载别人的代码
比如我们要下载springside,可以cd到任何目录,比如d盘,键入如下指令
git clone https://github.com/springside/springside4.git
下面命令用来关联远程代码库到一个名字
cd D:\git\springside4\springside4
git remote add springside4 https://github.com/springside/springside4.git
下面命令用来更新代码
git fetch springside4
7.打开Windows explorer时TortoiseGit无限崩溃的问题
[b]2014/04/12更新[/b]
经过本人的亲测,我的win7 32bit上,以下版本的TortoiseGit会无限崩溃,根本无法使用。
TortoiseGit-1.8.4
TortoiseGit-1.8.7
TortoiseGit-1.8.8
1.8.4版本在刚装好后的确ok,但是一重启系统就又有崩溃的问题了。
[b]2014/06/16更新[/b]
试了一下msysgit1.9.4 + TortoiseGit-1.8.9 终于不崩溃了,可以用了。如果还不行,试试安装时点击右键-->以管理员身份运行。并且安装时不要勾选安装error report组件。
8.其他的GUI
目前我试了一款[url=http://www.sourcetreeapp.com/]sourcetree[/url],这款GUI工具需要win7和.net4.5,文件比较可以调用外部工具如winmerge,beyond compare,觉得还可以。缺点是没有集成到Windows explorer,且需要注册。
1.下载安装[url=https://github.com/msysgit/msysgit/releases/]msysgit[/url]
2014/04/12更新: 官网已经从googlecode迁移到github了。下载最新版msysgit1.9.4.
在安装过程中会询问是否修改环境变量,选择Use Git Bash Only
[img]http://dl2.iteye.com/upload/attachment/0088/6442/bed83a37-15e3-3ba4-8e2d-138056d9d86a.jpg[/img]
SSH选择用git自带的就可以了。
[img]http://dl2.iteye.com/upload/attachment/0088/6444/57dde65e-76ee-3d66-a29f-df24224076a3.jpg[/img]
还会询问换行符的转换方式,使用默认设置就可以了。
[img]http://dl2.iteye.com/upload/attachment/0088/6446/c01cdd93-787d-3b59-b0ae-53ce7fa4c76a.jpg[/img]
2.如果只是要命令行操作,msysgit就够了。如果要GUI操作,可以下载安装[url=http://code.google.com/p/tortoisegit/]tortoisegit[/url]或者[url=http://www.sourcetreeapp.com/]sourcetree[/url]等等其他工具。
3.如果要操作Github的,还没账号的话去[url]https://github.com/[/url]注册吧
4.配置
参考[url]https://help.github.com/articles/set-up-git[/url]
$git config --global user.name "Your Name Here"
$git config --global user.email "your_email@example.com"
请确保 name 和 email 信息与在 GitHub 注册时的信息相符(当然每个项目还是可以单独设置的,比如你自己公司的私服你可以在项目里重设name和email)。
紧接着创建一个 SSH Public Keys,输入:
ssh-keygen -t rsa -C "username@email.com" 回车后,你会看到类似画面:
Generating public/private rsa key pair. Enter file in which to save the key (~/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in ~/.ssh/id_rsa.
Your public key has been saved in ~/.ssh/id_rsa.pub.
The key fingerprint is: e8:ae:60 ......
此时,你需要的 SSH Public Keys 就保存在 id_rsa.pub 文件中,找到并打开它,将里面的代码复制到 Account Settings 的相应区域(github网站上)。
5.如果对上面的操作不熟悉,可使用GUI工具创建ssh key
5.1 github提供了一个简便的工具GitHub for Windows
[url]http://github-windows.s3.amazonaws.com/GitHubSetup.exe[/url]
下载安装,并按照提示简单的几步就创建好了一个shh key,创建好的key在如下目录
C:\Users\xxx\.ssh\github_rsa.pub
而且在https://github.com/settings/ssh上面也可以看到。
5.2 msysgit自带一个gui工具可能更好,打开Git GUI,帮助->Show SSH key,点击generate key也可以生成。
6.如何下载别人的代码
比如我们要下载springside,可以cd到任何目录,比如d盘,键入如下指令
git clone https://github.com/springside/springside4.git
下面命令用来关联远程代码库到一个名字
cd D:\git\springside4\springside4
git remote add springside4 https://github.com/springside/springside4.git
下面命令用来更新代码
git fetch springside4
7.打开Windows explorer时TortoiseGit无限崩溃的问题
[b]2014/04/12更新[/b]
经过本人的亲测,我的win7 32bit上,以下版本的TortoiseGit会无限崩溃,根本无法使用。
TortoiseGit-1.8.4
TortoiseGit-1.8.7
TortoiseGit-1.8.8
1.8.4版本在刚装好后的确ok,但是一重启系统就又有崩溃的问题了。
[b]2014/06/16更新[/b]
试了一下msysgit1.9.4 + TortoiseGit-1.8.9 终于不崩溃了,可以用了。如果还不行,试试安装时点击右键-->以管理员身份运行。并且安装时不要勾选安装error report组件。
8.其他的GUI
目前我试了一款[url=http://www.sourcetreeapp.com/]sourcetree[/url],这款GUI工具需要win7和.net4.5,文件比较可以调用外部工具如winmerge,beyond compare,觉得还可以。缺点是没有集成到Windows explorer,且需要注册。