1.首次安装时.如何切换git的默认目录?
打开桌面快捷方式,删除目标结尾 “--cd-to-home”.修改起始位置为需要修改的启动目录.
2.添加当前文件夹中所有文件到上传列表中报错.
$ git add .
warning: LF will be replaced by CRLF in .idea/compiler.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in .idea/gradle.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in .idea/misc.xml.
..........
解决办法:
下面命令好像是设置全局代码自动换行 的状态为false
$ git config --global core.autocrlf false
3.最后一步上传出错
$ git push -u origin master
Username for 'https://git.oschina.net': mygit
To https://git.oschina.net/mygit/Jpush.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://git.oschina.net/mygit/Jpush.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 integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
解决办法:
1重新添加远程仓库地址.
$ git remote add origin https://git.oschina.net/mygit/Jpushgit
fatal: remote origin already exists.
A.1添加远程仓库地址出错
解决办法: 删除远程仓库.
$ git remote rm origin
B.重新添加远程仓库地址.
$ git remote add origin https://git.oschina.net/mygit/Jpushgit
C.执行数据上传
$ git push -u origin master
Username for 'https://git.oschina.net': mygit
Counting objects: 117, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (87/87), done.
Writing objects: 100% (117/117), 17.14 MiB | 327.00 KiB/s, done.
Total 117 (delta 20), reused 0 (delta 0)
remote: Resolving deltas: 100% (20/20), done.
To https://git.oschina.net/mygit/Jpush.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin by rebasing.
D.上传完成.
4.问题3还有一种解决办法:
使用命令
$ git pull --rebase origin master 合并远程仓库文件到本地.然后再次进行上传.
5.上传文件时出错:
error: src refspec master does not match any..
错误信息上传为内容为空.git上传到远程仓库时需要先用<git add 上传的文件名.md> 将上传的文件添加到上传队列.
6.git操作错误及解决办法集合.
参考博客:
http://blog.csdn.net/dengjianqiang2011/article/details/9260435