您的位置:首页 > 运维架构

Windows+Git+TortoiseGit+COPSSH 安装教程及问题收集

2017-07-07 17:45 691 查看
准备工作:

1、 git-1.8.1.2-preview20130201.exe

下载地址:

https://code.google.com/p/msysgit/downloads/list

2、 Copssh_4.1.0_Installer.exe

下载地址:

http://download.csdn.net/download/zzjzmdx/4636227

3、 TortoiseGit-1.8.5.0-64bit.msi

下载地址:

https://code.google.com/p/tortoisegit/wiki/Download?tm=2

服务器系统:Windows Server 2003 SP2

客户端系统:Windows 7 SP1

服务器端安装及部署

1、安装Git













此处选择默认安装



此处选择第三个,不去转换成unix的代码风格



完成安装

2、安装SSH及配置用户







安装在根目录下,避免路径中有空格,造成不必要的麻烦



此处是设置SSH的帐号密码





安装好后提示通过“COPSSH Control Panel”添加用户



完成安装



开始配置SSH用户



选中“Users”选项卡,点击Add按钮添加用户





选择用户名,此处可以选择刚刚安装SSH时设置的“SvcCOPSSH”用户,也可以自己新建一个用户来操作,本教程新建了一个GitAdmin的用户作为管理账户。





安装完成后还有两个操作:

1、将Git安装目录D:\Program Files\Git\libexec\git-core文件夹下的git-upload-pack.exe、git.exe、git-receive-pack.exe和git-upload-archive.exe这4个文件复制到SSH的安装路径D:\ICW\bin下。

2、将Git安装目录D:\Program Files\Git\bin\libiconv-2.dll复制到D:\ICW\bin下。

3、连接Git版本库



进入SSH安装目录下的bin文件夹,调用ssh.exe文件,输入以下代码:

“ssh GitAdmin@你的服务器名称或者IP地址”



键入yes



输入密码



看到这个界面,代表连接成功。此时你已经通过SSH协议连接上了Git。

4、建库操作

登录完成后,此时的实际路径是在D:\ICW\home\GitAdmin

建库操作步骤如下:

mkdir testgit //创建testgit文件夹

cd testgit //进入testgit文件夹

git init //版本库初始化,会以testgit为库名建立一个新库

touch first.txt second.txt //创建first.txt和second.txt文本文档

git add . //将文件添加至Git

git config –global user.email “you@example.com”//设置邮箱地址

git config –global user.name “Your Name” //设置用户名

git commit –m “init” //将修改提交至Git

cd ~/.ssh //进入.ssh文件夹

ssh-keygen –t rsa –C “you@example.com” //生成公钥,默认名称为id_rsa

至此,服务器端的安装与配置完毕。

注:Git默认设置克隆版本修改master版本内信息后不能提交修改,如需开放权限,要修改.git/config文件后面添加如下代码:

[receive]

denyCurrentBranch = ignore

客户端安装与配置

1、安装Git

安装步骤与服务器端相同。

2、安装TortoiseGit











安装完毕



此时在你的电脑鼠标右键就能看到Git已经集成到了系统快捷操作中。

3、配置TortoiseGit

首先设置TortoiseGit>Settings>Network中SSH client的值为”d:\Program Files(x86)\Git\bin\ssh.exe”。



新建测试local文件夹,右键选中Git Clone选项,会弹出对话框,输入正确的URL,选择Web方式,选好本地的文件夹,点击确定。



URL正确的话,会弹出输入密码界面,输入正确后,会将库信息克隆到本地。



看到Success,恭喜你,你已经获取到了服务器上的库信息。

以上转载http://blog.csdn.net/aaron_luchen/article/details/10498181

-------------------------------------------------------------------------------------------------------------------------------------------

问题:TortoiseGit disconnected no supported authentication

今天,我发现一个从远程服务器上获取到的工程,用Git没问题,而TortoiseGit报错:
Disconnected: No supported authentication methods available(server sent: publickey)



因为TortoiseGit和git的冲突。 改正如下:

1、TortoiseGit -> Settings -> Network

2、将SSH client设置成 Git\bin\usr\ssh.exe

然后,TortoiseGit 就可以正常工作了!

-------------------------------------------------------------------------------------------------------------------

在图形界面中,执行拉取操作时,出现下面的错误。

You asked to pull from the remote 'origin', but did not specify
a branch. Because this is not the default configured remote
for your current branch, you must specify a branch on the command line.

解决办法:

Edit your
.git/config


[branch "master"]
remote = origin
merge = refs/heads/master


Now you can simply git push and git pull.

-------------------------------------------------------------------------------

查看当前项目有哪些远程仓库

$ git remote

bixiaopeng@bixiaopengtekiMacBook-Pro wirelessqa$ git remoteorigin

查看远程仓库

$ git remote -v

bixiaopeng@bixiaopengtekiMacBook-Pro wirelessqa$ git remote -vorigin     git@gitlab.***.com:xiaopeng.bxp/wirelessqa.git (fetch)
origin git@gitlab.***.com:xiaopeng.bxp/wirelessqa.git (push)

查看远程仓库信息

$ git remote -v <remote-name>

bixiaopeng@bixiaopengtekiMacBook-Pro wirelessqa$ git remote show origin
* remote origin
Fetch URL: git@gitlab.****.com:xiaopeng.bxp/wirelessqa.git
Push  URL: git@gitlab.***.com:xiaopeng.bxp/wirelessqa.git
HEAD branch: master
Remote branch:
master tracked
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (local out of date)

添加远程仓库:

$ git remote add [remote-name] " target=_blank>
[/code]
bixiaopeng@bixiaopengtekiMacBook-Pro robotium$ git remote add test git://github.com/paulboone/ticgit.git
bixiaopeng@bixiaopengtekiMacBook-Pro robotium$ git remote -vorigin
https://github.com/RobotiumTech/robotium (fetch)
origin https://github.com/RobotiumTech/robotium (push)
test git://github.com/paulboone/ticgit.git (fetch)
test git://github.com/paulboone/ticgit.git (push)

[title2][url=http://blog.csdn.net/wirelessqa/article/details/20152651#%E5%88%A0%E9%99%A4%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%93]删除远程仓库:
$ git remote rm [remote-name]

bixiaopeng@bixiaopengtekiMacBook-Pro robotium$ git remote rm test
bixiaopeng@bixiaopengtekiMacBook-Pro robotium$ git remote -vorigin https://github.com/RobotiumTech/robotium (fetch)
origin https://github.com/RobotiumTech/robotium (push)

[url=http://blog.csdn.net/wirelessqa/article/details/20152651#%E4%BF%AE%E6%94%B9%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%93]修改远程仓库:

$ git remote set-url --push [remote-name] [newUrl]

重命名远程仓库

$ git remote rename <old-remote-name> <new-remote-name>

从远程仓库抓取数据 :

$git fetch [remote-name]

说明:

此命令会到远程仓库中拉取所有你本地仓库中还没有的数据。运行完成后,你就可以在本地访问该远程仓库中的所有分支

fetch 命令只是将远端的数据拉到本地仓库,并不自动合并到当前工作分支,只有当你确实准备好了,才能手工合并

拉取远程仓库:

$ git pull [remote-name] [本地分支名]

说明: 一般我们获取代码更新都是用Git pull, 目的是从原始克隆的远端仓库中抓取数据后,合并到工作目录中的当前分支

推送远程仓库:

$ git push [remote-name] [本地分支名]

说明: 只有在所克隆的服务器上有写权限,或者同一时刻没有其他人在推数据,这条命令才会如期完成任务。 如果在你推数据前,已经有其他人推送了若干更新,那你的推送操作就会被驳回。你必须先把他们的更新抓取到本地git pull,合并到自己的项目中,然后才可以再次推送。

$git push origin test:master         // 提交本地test分支作为远程的master分支
$git push origin test:test              // 提交本地test分支作为远程的test分支
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: