问题:nothing added to commit but untracked files present
解决方案:
不想提交文件
添加git忽略文件 .gitignore
将不想提交的文件写入到.gitgnore文件中。记得要把.gitignore也添加进来
vim .gitignore
/target/
zblog.iml
想提交文件
将这些文件或文件夹add进去
git add /target/.
git add zblog.iml
问题:git如何添加文件夹
· git add -A 提交所有变化
· git add -u 提交被修改(modified)和被删除(deleted)文件,不包括新文件(new)
· git add . 提交新文件(new)和被修改(modified)文件,不包括被删除(deleted)文件
git版本不同会有所区别:
Git Version 1.x:
Git Version 2.x:
问题:error: src refspec master does not match any
原因分析:
引起该错误的原因是目录中没有文件,空目录是不能提交上去的
解决办法:
$ touch README
$ git add README
$ git commit –m’first commit’
$ git push origin master
问题:执行git push出现"Everything up-to-date"
原因分析:
- 没有git add .
- 没有git commit -m "提交信息"
如果上面两个步骤都成功执行,还出现这个错误是因为创建的目录下是空的,目录下必须有文件才能git push上传成功。
在github上创建文件的时候,在新文件名后加/符号就是文件夹,但是这种方式只支持英文名目录,中文名目录不支持。
要是想创建中文名文件夹,就通过客户端工具或终端命令行实现。
如果在github一个文件夹下只有一个文件,那么删除这个文件的同时,它所在的文件夹也一同删除了。
问题:# Please enter the commit message for your changes. Lines starting # with '#' will be ignored
原因分析:
提交的命令为: git commit
修改提交命令为 : git commit -m "注释"
问题:fatal: Not a git repository
原因分析:
提示说没有.git这样一个目录,解决办法如下:
git init就可以了!
问题:fatal: Pathspec 'xxx' is in submodule
解决方案:
发现git/bpmsboot下面并没有.git文件
所以使用下面命令:
git rm -rf --cached git/bpmsboot
git add git/bpmsboot/*
问题:Please make sure you have the correct access rights and the repository exists.
原因分析:
ssh key有问题,连接不上服务器
解决方案:
- 重新在git设置一下身份的名字和邮箱
-
git config --global user.name "yourname" git config --global user.email“[email protected]"
- 删除.ssh文件夹(直接搜索该文件夹)下的known_hosts
-
git输入命令
$ ssh-keygen -t rsa -C "[email protected]"
接着出现:
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/your_user_directory/.ssh/id_rsa):
然后系统会自动在.ssh文件夹下生成两个文件,id_rsa和id_rsa.pub,用记事本打开id_rsa.pub
将全部的内容复制
-
打开https://github.com/,登陆你的账户,进入设置,在setting中设置"SSH and GPG keys"
-
ssh -T [email protected]
-
输入命令:yes
问题:he file will have its original line endings in your working directory.
解决方案:
git config –global core.autocrlf false
原因分析:
原因是路径中存在 / 的符号转义问题,false就是不转换符号默认是true,相当于把路径的 / 符号进行转义,这样添加的时候就有问题