防止在Git中推送本地更改 [英] Prevent local changes getting pushed in Git

查看:134
本文介绍了防止在Git中推送本地更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我克隆了一个仓库,我的仓库中的 master 分支正在跟踪 origin / master 。我创建了一个 work 分支,并更改了一些特定于我的开发机器的配置文件,以使应用程序可以正常工作。



我的正常的工作流程将切换到 master 分支,合并在工作分支和分支中进行的更改上游的这些变化。问题是我不希望我的特定chnages被推动。当我将工作分支合并到 master 时,这些更改也会合并。



我迄今发现的唯一解决方案不是在 work 中提交这些更改,但这并不令人满意解决方案。如果你想阻止提交(因此也推送)这些本地配置文件,你可以使用 http://gitready.com/intermediate/2009/02/18/temporarily-ignoring-files.html =noreferrer> git update-index --assume-unchanged 。标有此标志的文件将被假定为永远不会改变(直到您用--no-assume-不变)重置标志)


I have cloned a repository and the master branch in my repo is tracking origin/master. I created a work branch and changed some config files specific to my dev machine to make the app work.

My normal workflow will be to switch to master branch, merge changes made in work branch and push those changes upstream. The problem is that i don't want my specific chnages to get pushed. When i merge my work branch into master those changes are merged also.

The only solution I've found so far is not to commit those changes in work but that's not a satisfactory solution.

解决方案

If you want to prevent committing (therefore also pushing) these local config files, you could use git update-index --assume-unchanged. Files marked with this flag will be assumed to never change (until you reset the flag with --no-assume-unchanged)

这篇关于防止在Git中推送本地更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆