如果输入$ git push origin master
提示出错信息:error:failed to push som refs to .......
解决办法如下:
1、先输入$ git pull origin master //先把远程服务器github上面的文件拉下来
2、再输入$ git push origin master
3、如果出现报错 fatal: Couldn't find remote ref master或者fatal:'origin' does not appear to be a git repository以及fatal:Could not read from remote repository.
4、则需要重新输入$ git remote add origin
如果输入$ git push origin master
error: failed to push some refs to 'git@git.oschina.net:summving/XXXXXXXXX.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first merge the remote changes (e.g.,
hint: 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
解释的已经很清楚了。因为远程仓库比你的本地库更新,所以你得先 pull 下,再 push 就 ok 了。
没有设定远程跟踪分支的话 你要使用这个命令 git pull origin master
如果输入$ git remote add origin
提示出错信息:fatal: remote origin already exists.
解决办法如下:
1、先输入$ git remote rm origin
2、再输入$ git remote add origin 就不会报错了!
3、如果输入$ git remote rm origin 还是报错的话,error: Could not remove config section'remote.origin'. 我们需要修改gitconfig文件的内容
4、找到你的github的安装路径,我的是C:\Users\ASUS\AppData\Local\GitHub\PortableGit_ca477551eeb4aea0e4ae9fcd3358bd96720bb5c8\etc
5、找到一个名为gitconfig的文件,打开它把里面的[remote"origin"]那一行
删掉就好了!
如果输入$ ssh -T
解决办法如下:
1、先输入$ ssh-agent,再输入$ ssh-add ~/.ssh/id_key,这样就可以了。
2、如果还是不行的话,输入ssh-add ~/.ssh/id_key 命令后出现报错Could not opena connection to yourauthentication agent.解决方法是key用Git Gui的ssh工具生成,这样生成的时候key就直接保存在ssh中了,不需要再ssh-add命令加入了,其它的user,token等配置都用命令行来做。
3、最好检查一下在你复制id_rsa.pub文件的内容时有没有产生多余的空格或空行,有些编辑器会帮你添加这些的。
使用git在本地创建一个项目的过程
$ makdir ~/hello-world //创建一个项目hello-world
gitconfig配置文件
Git有一个工具被称为git config,它允许你获得和设置配置变量;这些变量可以控制Git的外观和操作的各个方面。这些变量可以被存储在三个不同的位置:
配置相关信息:
$git config --global user.name "John Doe"
$git config --global user.email
2.2 你的编辑器(YourEditor)
现在,你的标识已经设置,你可以配置你的缺省文本编辑器,Git在需要你输入一些消息时会使用该文本编辑器。缺省情况下,Git使用你的系统的缺省编辑器,这通常可能是vi 或者 vim。如果你想使用一个不同的文本编辑器,例如Emacs,你可以做如下操作:
$git config --global core.editor emacs
2.3 检查你的设置(Checking Your Settings)
如果你想检查你的设置,你可以使用 git config --list 命令来列出Git可以在该处找到的所有的设置:
$git config --list
你也可以查看Git认为的一个特定的关键字目前的值,使用如下命令 git config {key}:
$git config user.name
2.4 获取帮助(Getting help)
如果当你在使用Git时需要帮助,有三种方法可以获得任何git命令的手册页(manpage)帮助信息:
$git help <verb>
$git <verb> --help
$man git-<verb>
例如,你可以运行如下命令获取对config命令的手册页帮助:
$git help config
参考资料:http://blog.163.com/023_dns/blog/static/1187273662013111301046930/
因篇幅问题不能全部显示,请点此查看更多更全内容