简体   繁体   English

如何告诉git忽略本地更改,但将文件保留在远程仓库中?

[英]How do I tell git to ignore my local changes, but leave the file in my remote repo?

Constantly changing my web.config file when testing/pushing to production gets old, so does having to remember to remove that from my staged changes when I don't change the file. 在测试/推送到生产环境时,不断更改我的web.config文件变得陈旧,因此一定要记住,当我不更改文件时,请从我的阶段更改中删除该文件。

I have tried using selecting the "stop tracking" option in Sourcetree (which I think adds the file to my GitIgnore), but that looks like it will remove the file from my remote repo. 我尝试使用Sourcetree中的“停止跟踪”选项(我认为该选项会将文件添加到我的GitIgnore中),但是看起来它将从我的远程仓库中删除该文件。

Is it possible to leave a file in my remote repo, and stop tracking local changes? 是否可以远程仓库中保留文件,并停止跟踪本地更改?

Use the following command: 使用以下命令:

git update-index --assume-unchanged <filename>

If you want to undo it later, use: 如果要稍后撤消,请使用:

git update-index --no-assume-unchanged <filename>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Git和TortoiseSVN,我如何撤消本地存储库中的更改,而无需再次克隆远程仓库 - Git and TortoiseSVN, how do i undo my changes in local repository without cloning the remote repo again 我的本地git repo已“未暂存”已删除的文件,远程是文件,如何提取丢失的文件? - my local git repo has “not staged” deleted files, remote is file, how do I pull the missing files? 我可以将文件添加到本地Git存储库中,但不能将其推送到远程 - Can I add a file to my local Git repo but not push it to remote Git:目前与私人远程仓库合并/冲突。 如何告诉Git只使用我的本地文件? - Git: currently in merge/conflict with private remote repo. How to tell Git to just use my local files? 如果还没有与我的本地存储库链接的远程存储库,我如何 go 到克隆的存储库并签入 git bash? - How do I go to the cloned repo and check in git bash if there isn't already a remote repo linked with my local repo? 如何在我的本地git克隆回购之前判断github回购是否 - How to tell if github repo ahead of my local git cloned repo 当我在本地仓库中明确进行更改时,为什么 git 告诉我“我的分支是最新的”? - Why does git tell me “my branch is up to date” when I clearly made changes in local repo? 如何将我的远程git仓库移动到另一个远程git仓库? - How do I move my remote git repo to another remote git repo? 如何忽略“git pull”上关于我的本地更改将被合并覆盖的错误? - How do I ignore an error on 'git pull' about my local changes would be overwritten by merge? 如何将 git fork 的更改合并到我的 repo 的 master 中? - How do I merge changes of a git fork into master of my repo?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM