一、安装Git
安装步骤参考:
Git 详细安装教程(详解 Git 安装过程的每一个步骤)mukes的博客-CSDN博客git安装
二、Git + 码云的使用
入门教程参考:
git + 码云 使用详解(入门)(mac+windows教程)ai1362425349的博客-CSDN博客git码云使用教程
三、添加文件步骤
文件路径中右键“Git Bash Here”,运行:
$ git add .
$ git commit -m ''
$ git push origin master
四、问题记录
1、问题:输入命令“git add .
”后报错
$ git add .
error: 'xxx/' does not have a commit checked out
fatal: adding files failed
解决方法:删除 xxx/文件夹下的 .git 隐藏文件
2、问题:输入命令“git add .
”后警告
warning: LF will be replaced by CRLF in ball_pool/assets/Main.js.
The file will have its original line endings in your working directory
解决方法:发生的原因是路径中存在 / 的符号转义问题,false就是不转换符号默认是true,相当于把路径的 / 符号进行转义,这样添加的时候就有问题。这个提示的意思是说会把windows格式(CRLF,即回车换行)转换成Unix格式(LF),git默认支持LF。这些警告不影响使用。
可运行如下代码解决该问题:
git config --global core.autocrlf false
3、问题:输入命令“git push origin master
”后报错
$ git push origin master
To gitee.com:xxx.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'gitee.com:xxx.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
解决方法:可能gitee中某些文件被删掉不在本地代码目录中,故先使用“git pull --rebase origin master
”拉取线上仓库,再使用git add ,git commit,git push
$ git pull --rebase origin master
From gitee.com:xxx
branch master -> FETCH_HEAD
Successfully rebased and updated refs/heads/master.
再输入“git push origin master
”后成功上传。