git ssh安装与使用(持续)

我在我的windows 机器上安装了Git-1.8.0-preview20121022.exe这个,然后在linux服务器端上安装了git,之后是配置ssh变成不用密码自动登录,这个我的文章里有。在linux上配置仓库命令如下:

 984  mkdir gitrepos
  985  cd gitrepos/
  986  ls
  991  /usr/local/git/bin/git init --bare

之后我在我的windows机器上运行Git Bash,生成ssh密钥,放在linux上(文章里有),在h盘建立仓库:

$ cd gitrepos
$ git init
$ git add .
$ git commit -m 'initial commit'
$ git remote add origin root@10.11.157.61:/opt/gitrepos

$ git push origin master

这样就会建立本地和远程的链接,在本地的/H/gitrepos/gitrepos/.git/config里自动会生成配置如下:

[remote "origin"]
        url = root@10.11.157.61:/opt/gitrepos
        fetch = +refs/heads/*:refs/remotes/origin/*

这样在Git Bash里敲:

git add .

git commit -am "test git"

git push origin master

就会把我的windows机器的git仓库里的文件提交到linux的git服务器上建立的仓库里。

问题汇总:

1.在执行

$ git remote addorigin git@github.com:defnngj/hello-world.git

错误提示:fatal: remote origin already exists.

解决办法:

$ git remote rm origin

然后在执行:$ git remote add origin git@github.com:defnngj/hello-world.git 就不会报错误了

2. 在执行

$ git push origin master

错误提示:error:failed to push som refs to.......

解决办法:

$ git pull origin master //先把远程服务器github上面的文件拉先来,再push 上去。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值