GIT常用命令和常见问题解决方法

mofyi | colin



git pull 提示错误,Your local changes to the following files would be overwritten by merge

解决办法:
1、服务器代码合并本地代码

$ git stash     //暂存当前正在进行的工作。

$ git pull   origin master //拉取服务器的代码

$ git stash pop //合并暂存的代码

2、服务器代码覆盖本地代码

$git reset --hard  //回滚到上一个版本

$git pull origin master 

3https永久记住密码

不需要每次在输入用户名密码

git config --global credential.helper store

会在用户主目录的.gitconfig文件中生成下面的配置。

[credential]

    helper = store

如果没有–global,则在当前项目下的.git/config文件中添加。
当然,你也可以直接复制上面生成的配置到配置文件中。