git - With Git how do I insert a modified file into the master branch
问题描述
I just have a master branch, I need to go back to an earlier tag to modify the pom.xml
file and then release it to Maven Central. So I want to edit the file and then commit it, but if I do that and then swap back to the latest commit I assume I will see that modified file as the latest file when I do git checkout
back to HEAD, which would be wrong.
So how do I insert a modified file into the master branch?
git checkout tag/v2.2.5
edit pom.xml
# commit somehow, and push to remote
mvn release
git checkout
At this point, the current code should look the same as it did to start with.
解决方案
Okay from the comments it seems is not possible, so as the purpose was to make a change to the build file so that I could just deploy the builds to the Maven repository I did the following instead:
git checkout tag/v2.2.5
edit pom.xml
mvn clean deploy -Prelease
git reset --hard
git checkout master
So I used git to go to the right place and make the edit, I did the build and then just discarded the edit.
推荐阅读
- elixir - Elixir - 为什么这些重复的头文件没有编译器警告?
- android - Android Studio 的相同项目中不显示布局
- sql - 这两个字符串有什么区别?
- java - 使用 Java.net 的 Http 功能验证和发送请求
- java - MapStruc lib 的@Mapper(componentModel = "spring") 用于自动接口实现错误
- html - 如何在 django 的 html 模板中显示搜索查询的数据?
- angular - 带有路由选项卡的 Angular Material Routed 对话框
- qt - 无法覆盖 Qt QML 表单实现中的属性/实现处理程序
- foursquare - Foursquare API:如何在“自治市镇”等行政区域内探索场地
- laravel - 有没有办法通过命令行在 laravel 中制作服务容器文件?