我在我的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 上去。