git pull 每次都要求输入用户名和密码
# 全局配置
git config --global credential.helper store
# 局部配置
git config credential.helper store
# 查看git配置
git config --list
设置用户名和邮箱
# 请替换你的用户名
git config --global user.name "Your Name"
# 请替换你自己的邮箱
git config --global user.email "your@email"
git pull 发生文件冲突
error: Your local changes to the following files would be overwritten by merge:
public/file/xxx.docx
Please, commit your changes or stash them before you can merge.
Aborting
git reset --hard
git pull
配置ssh秘钥
# 1.创建 SSH 密钥
# 判断是否已经存在本地公钥
cat ~/.ssh/id_rsa.pub
# 如果查询不到本地公钥,你可以按如下命令来生成 SSH 密钥
ssh-keygen -t rsa -C "<邮箱>"
# 复制公钥添加到个人设置 -「SSH 密钥」下,请完整拷贝从 ssh- 开始直到你的用户名和主机名为止的内容。
# 如果打算拷贝公钥到你的粘贴板下,请参考操作系统使用以下命令:
Windows:
clip < ~/.ssh/id_rsa.pub
Mac:
pbcopy < ~/.ssh/id_rsa.pub
GNU/Linux (requires xclip):
xclip -sel clip < ~/.ssh/id_rsa.pub
已有文件夹或者仓库
cd file
git init
git remote add origin xxx.git
git add .
git commit
git push -u origin master
去除版本控制
# -n:加上这个参数,执行命令时,是不会删除任何文件,而是展示此命令要删除的文件列表预览。
git rm -r -n --cached ".vs/"
# 最终执行命令
git rm -r --cached ".vs/"
# 提交
git commit -m "message"
# 提交到远程服务器
git push origin master