Debian Java项目的版本控制实践
一 基础环境准备
sudo apt-get update && sudo apt-get install gitgit config --global user.name "Your Name";git config --global user.email "your.email@example.com"sudo apt-get install openjdk-11-jdk -yjava -versionssh-keygen -t rsa -b 4096 -C "your.email@example.com"cat ~/.ssh/id_rsa.pub | ssh 用户名@git服务器地址 "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"二 本地版本控制流程
git init,将源码纳入版本控制,完成首次提交。
git add .git commit -m "Initial commit"git checkout -b feature/your-featuregit checkout main && git merge feature/your-featuregit remote add origin <repo-url>git push -u origin maingit pull origin maingit add <file> → `git commit -m “Resolve merge conflicts”三 版本号与发布打标
git tag -a v1.0.1 -m "Release version 1.0.1"git push origin v1.0.1mvn clean install;运行:java -jar target/your-app-1.0-SNAPSHOT.jargradle build四 自动化与进阶
update-alternatives 管理多个 Java 版本,便于在不同项目间切换。
sudo update-alternatives --config java<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>5.13.0.202109080827-r</version>
</dependency>
target/
build/
.idea/
*.iml
*.log