Git 如何忽略已经提交过的文件?

git pull 代码时经常遇到的问题

mao-siyu@mao-siyu-PC:~/文档/code/bigdata/client$ git pull
error: Your local changes to the following files would be overwritten by merge:
        .idea/workspace.xml
Please, commit your changes or stash them before you can merge.
Aborting
mao-siyu@mao-siyu-PC:~/文档/code/bigdata/client$

处理方法

mao-siyu@mao-siyu-PC:~/文档/code/bigdata/client$ git rm --cached .idea/workspace.xml
rm '.idea/workspace.xml'
mao-siyu@mao-siyu-PC:~/文档/code/bigdata/client$

修改 .gitignore

# dependencies
node_modules

# logs
npm-debug.log

# Nuxt build
.nuxt

# Nuxt generate
dist

# idea/ all
.idea/

最后 提交 .gitignore文件


发表评论

电子邮件地址不会被公开。 必填项已用*标注