在Debian下对JS项目进行版本控制,主要使用Git工具,步骤如下:
安装Git:
sudo apt update
sudo apt install git
配置用户名和邮箱:
git config --global user.name "Your Name"
git config --global user.email "your_email@example.com"
初始化仓库:
在项目目录下执行:
git init
添加文件并提交:
git add . # 添加所有文件
git commit -m "Initial commit"
关联远程仓库:
git remote add origin <远程仓库URL>
git push -u origin main # 推送至主分支
分支管理(可选):
创建分支:
git branch feature-branch
切换分支:
git checkout feature-branch
合并分支:
git checkout main
git merge feature-branch
忽略文件:
创建.gitignore
文件,排除node_modules/
等无需版本控制的文件。
说明:依赖管理使用npm
或yarn
,通过package.json
和yarn.lock
/npm-shrinkwrap.json
锁定版本,需将配置文件纳入Git管理。