8: Removing Cached Files(Merge Conflicts )

As mentioned in the previous screen, adding files to .gitignore doesn't remove any files that have already been added to a git commit. Any changes to these files will still be tracked by git, and added to future commits. This can be frustrating, especially when those files cause merge conflicts that take effort to resolve.

In situations like this, removing files from the git cache can be helpful. This will prevent git from tracking changes in those files, and adding them into future commits.

This can be done with the git rm command, and the --cached flag. For example, the below command will remove any file called .DS_Storefrom the git cache, and prevent it from being tracked:

 

git rm --cached .DS_Store

This will remove any files called .DS_Store from your git repo, but not from your working directory. The files will still exist on your computer, but be invisible to git for version tracking purposes.

Instructions

  • Switch into the /home/dq/chatbot repo.
  • Switch to the master branch.
  • Remove bot.py from the git cache.
  • Commit your changes with the message Removed bot.py. Remember not use git add here, as this will add bot.py back in!
  • Push the master branch to the remote

~$ cd ~

~$ cd chatbot

~$ git checkout master

~$ git rm --cached bot.py

~$ git commit -m "Removed bot.py"

~$ git push origin master

转载于:https://my.oschina.net/RobertPattins/blog/747126

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值