Git 拉取时的命令行和遇到的问题
简易的命令行入门教程:
Git 全局设置:
git config --global user.name "XXX"
git config --global user.email "XXX"
创建 git 仓库:
mkdir project_store
cd project_store
git init
touch README.md
git add README.md
git commit -m "first commit"
git remote add origin https://gitee.com/XXX
git push -u origin "master"
modified content, untracked content错误提示的处理
问题2
问题3
git push -u origin master 时
To https://gitee.com/XXXX.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://gitee.com/XXXX.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.
本地是先创建的,github上的仓库是后创建的。
解决办法:
在项目根目录命令行使用git pull origin master --allow-unrelated-histories。
命令行有进入编辑模式的话,输入英文冒号“:”然后输入“q”推出,commit一次。
再次同步即可。
问题5
git clone无响应或timeout ,或者速度慢?
原地址: https://github.com/PanJiaChen/vue-element-admin.git
1.在原地址前加 https://ghproxy.com/ ,如下所示:
git clone https://ghproxy.com/https://github.com/PanJiaChen/vue-element-admin.git
2.在原地址前加 https://gitclone.com/ ,如下所示:
git clone https://gitclone.com/https://github.com/PanJiaChen/vue-element-admin.git
问题7
从git上下载了好多代码,有时候会把仓库的地址忘掉,如何查看自己是在哪里拉取的代码呢?
解决
进入项目的根目录,执行
git remote -v
示例如下:
C:\Users\LMG\Desktop\练习>git remote -v origin https://gitee.com/XXXX.git (fetch) origin https://gitee.com/XXXX.git (push)
问题8
上传项目到git,如何忽略node_modules文件夹
根目录下创建.gitignoe文件
touch .gitignore

添加 node_modules/

问题9
上传本地文件到gitee远程仓库后,发现如下情况:
文件夹显示为灰色并且无法访问,不能点击。瞬间就慌了,不着急往下看。
根据上面的截图来看:
首先在对应文件夹下,打开终端,
运行: git rm -r --cached "02_vue_脚手架练习"然后在本地找到灰色文件夹中原本的.git文件手动删掉,注意显示隐藏文件去找,看上面的截图,
再然后重新 git add , commit , push 提交代码
最后成功提交文件夹,可以正常打开,如下图:
在这里顺便把,再次提交到远程仓库的代码给写一下:
git add 你要提交的文件 (全部提交 git add .)
git commit -m "这里面写,你提交代码时的备注,没要求"
git push
到这里应该就成功了,Good Luck!

浙公网安备 33010602011771号