1、未使用 git add 缓存代码,需要放弃本地修改
// 放弃单个文件修改,注意不要忘记中间的"--",不写就成了检出分支了!
git checkout -- filepathname
// 放弃所有的文件修改
git checkout .
2、已使用git add 缓存代码,需要先放弃缓存
//放弃单个文件缓存
git reset HEAD filepathname
//放弃所有缓存
git reset HEAD .
// 放弃单个文件修改,注意不要忘记中间的"--",不写就成了检出分支了!
git checkout -- filepathname
// 放弃所有的文件修改
git checkout .
3、已经commit了代码的情况
//清理本地缓存
git reset HEAD~
// 放弃单个文件修改,注意不要忘记中间的"--",不写就成了检出分支了!
git checkout -- filepathname
// 放弃所有的文件修改
git checkout .
4、进入.git目录
cd .git
5、输入局部配置信息
git config user.name 'test'
git config user.email 'test@qq.com'
git config user.password 'test'
6、全局配置
git config --global user.name 'test'
git config --global user.email 'test@qq.com'
git config --global user.password 'test'
7、查看
git config user.name
git config user.email
8、服务器修改密码
进入git配置文件
cd .git
vim config
将https路径复制到url中,保存
[remote "origin"]
url = https://code.aliyun.com/****/*****.git
fetch = +refs/heads/*:refs/remotes/origin/*
配置第一次需要输入密码,以后都不需要了
git config --global credential.helper store
9、服务器更新代码
git pull 更新(会出现更新不了的问题)
git reset --hard origin/master (查看更新位置)
git fetch --all 进行更新(更新前后进行查看位置)