git 更新远程代码到本地

git fetch origin master
git merge origin/master

冲突:

Your local changes to the following files would be overwritten by merge:
        index.html

如果希望保留生产服务器上所做的改动,仅仅并入新配置项, 处理方法如下:

git stash
git pull
git stash pop

然后可以使用git diff -w +文件名 来确认代码自动合并的情况.

反过来,如果希望用代码库中的文件完全覆盖本地工作版本. 方法如下:

git reset --hard
git pull

其中git reset是针对版本,如果想针对文件回退本地修改,使用

删除远程文件夹

git rm -r --cached 本地文件夹名字
git commit -m 'remove files'
git push origin master

忽略不需要上传的文件

假设当前文件目录如下:

f:/node
    >index.html
    >node_modules
        >...
    >package.js
    >.idea    

在工程下新建 .gitignore 文件,将不需要上传的文件夹或文件写入其中:

// 忽略文件夹
node_modules/

// 忽略文件
node_modules/index.html

相关文章:

  • 2022-01-09
  • 2021-07-13
  • 2021-07-14
  • 2021-07-31
猜你喜欢
  • 2021-11-23
  • 2021-09-26
  • 2021-11-07
  • 2021-12-15
  • 2021-10-19
  • 2021-11-29
  • 2021-05-01
相关资源
相似解决方案