gitlab本地文件 跨分支 忽略改动 不提交

第一步:从 git 缓存中移除(仅本地)

bash 复制代码
# skip-worktree(已被跟踪的文件,防止显示 M)
git update-index --skip-worktree mis-microservice/mis-microservice-impl/src/main/resources/application.yml
git update-index --skip-worktree mis-microservice/mis-microservice-impl/src/main/resources/bootstrap.yml

第二步:用 .git/info/exclude 代替 .gitignore

.git/info/exclude 是本地私有的忽略文件,永远不会被 git 提交到远程:

bash 复制代码
echo "*.yml" >> .git/info/exclude

如果想拉取git上别人改动的yml :

bash 复制代码
# 第一步:先取消 skip-worktree
git update-index --no-skip-worktree mis-microservice/mis-microservice-impl/src/main/resources/application.yml

# 第二步:拉取远程最新
git pull

# 第三步:手动 merge(如果你本地和队友都改了)
# 第四步:重新设回 skip-worktree
git update-index --skip-worktree mis-microservice/mis-microservice-impl/src/main/resources/application.yml

以后不管切什么分支,这三个文件在你本地都不会再被 git 跟踪了。想取消的时候:

bash 复制代码
# 取消 skip-worktree(比如你要提交 yml 改动)
git update-index --no-skip-worktree mis-microservice/mis-microservice-impl/src/main/resources/application.yml

# 清空 exclude(如果不想忽略 yml 了)
sed -i '' '/^\*\.yml$/d' .git/info/exclude
相关推荐
极小狐3 小时前
极狐GitLab集群高可用方案,多节点架构与故障自愈实践
架构·gitlab·高可用·极狐gitlab
极小狐1 天前
极狐GitLab主备同步延迟治理,复制滞后监控与优化方法
gitlab·极狐gitlab·geo容灾
极小狐1 天前
跨项目流水线报 404 Not Found?CI_JOB_TOKEN 允许名单 9 步排查
ci/cd·gitlab·devops·权限管理·流水线·极狐gitlab·作业令牌
极小狐2 天前
极狐GitLab双机热备搭建指南,主机备机部署与切换实操
gitlab·高可用·极狐gitlab
有同事要进步8 天前
如何在github或者是gitlab上创建空文件
gitlab·github
GoodStudyAndDayDayUp10 天前
gitlab私有化跑CICD
gitlab·gitlab私有化跑cicd
成为你的宁宁10 天前
【Gitlab测试项目】
gitlab·devops
_可乐无糖12 天前
GitLab CI 脚本之 CI_COMMIT_AUTHOR
ci/cd·gitlab
_可乐无糖13 天前
GitLab CI 脚本之 dependencies 和 needs
ci/cd·gitlab